After pushing changes from one client to a remote repository, how can I get them into the workspace of another?

Every time I push changes from my git repo to my staging server, I have to use the following command to complete overwrite the changes.

git fetch --all && git reset --hard origin/master

Why can’t I just do git fetch?

  • Why does a “git push” just hang there indefinitely using MySysGit 1.7.4?
  • Git - Having a private local “fork”
  • What does MM stand for in git show --raw output for merge commits?
  • Dealing With Multiple Git Heads locally and on the server
  • Git submodule track commit but know branch?
  • Backup only “local” commits / objects in git repository
  • Get commit that precedes a fork at Github
  • Git - Unmerge after other commits have been made
  • One Solution collect form web for “After pushing changes from one client to a remote repository, how can I get them into the workspace of another?”

    If you want to pull changes you need to use git pull not git fetch. fetch does only download the changes into the repository (and updates the remote branches). It does not update the workspace.

    git pull is a shortcut for git fetch && git merge <branch>. See for example the GitHub help.

    I typically use an alias fe = fetch --all -v -progress -p which I run often just to see what changes and differences happen. This can be done without thinking as it does not touch your workspace, require merging or similar (that is why git fetch is a useful command even if it has no obvious effect to the workspace). It does for example help with git status as it can tell you, that you are behind the remote branch (and need to run git pull --ff-only or similar).

    Git Baby is a git and github fan, let's start git clone.