git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git push requires a subsequent git reset --hard ?

From
Jakub Narebski <jnareb@gmail.com>
Date
Jul 1, 2008, 17:29 UTC
Message-ID
<m3vdzpfr16.fsf@localhost.localdomain>
In-Reply-To
<912ec82a0807010951j9e970f2k9624682b33c8af7d@mail.gmail.com>
"Neshama Parhoti" <pneshama@gmail.com> writes:
Show 13 quoted lines
> I took with me a copy of a local repository to a week away from my station
> (just rsync'ed it to my laptop).
> 
> On my return, I just "git push myuser@my-station:/my/git/repo" from my laptop.
> It seemed to work with no probs.
>
> On my station the git repo got the new commits, as I can see in
> git-log, but the actual files were left untouched.
> 
> So I need to do something like "git reset --hard HEAD" to get
> the changes into the local files.
> 
> Is that considered normal ?

This is considered normal. Push would never touch index nor working area (although if you are the only user, and you know what you are doing, you can add "git reset --hard HEAD" to post-receive hook). It is the only way: "push" cannot be opposite of "pull" and do a merge because there is nobody to resolve conflict on remote side.

So you should either do mirroring (1:1 refspec) push into bare repository (without working directory), or push into remotes section, remotes/satellite or remotes/mothership, like shown in GitFaq, below.

See also:
* "Why won't I see changes in the remote repo after "git push"?"
  http://git.or.cz/gitwiki/GitFaq#head-b96f48bc9c925074be9f95c0fce69bcece5f6e73
* "How would I use "git push" to sync out of a firewalled host?"
  http://git.or.cz/gitwiki/GitFaq#head-46de97a5ac549d3adf406c22674b3325ae25d09c
-- 
Jakub Narebski
Poland
ShadeHawk on #git
Previous: Jeff KingNext: Dmitry Potapov
Message 3 of 6 in “git push requires a subsequent git reset --hard ?”
  1. Neshama ParhotiJul 1, 2008
  2. Jeff KingJul 1, 2008
  3. Jakub NarebskiJul 1, 2008
  4. Dmitry PotapovJul 2, 2008
  5. Neshama ParhotiJul 4, 2008
  6. Dmitry PotapovJul 2, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.