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: ignore *.js only if *.coffee is present in the same directory
- What's the Mercurial equivalent for git hash-object and how do I get the hash of a certain commit?
- Failure Symfony2 deployment to platform sh. SQLSTATE
- How do I make Git ignore the contents of a file?
- Unable to reach Bash Shell on 'docker attach'
- Does github allow pre-receive hooks?
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).