What can I do after "git pull" and file's conflicts, if I don't want to continue, but just revert to the original state
When you do a git pull
, you are really doing a git fetch
followed by either a git merge
or a git rebase
. Assuming your pull strategy is using merge, then your question is how can you undo the merge done during a git pull
. One clean way to undo a merge is to reset your local branch to the latest commit:
git reset --hard <SHA-1 hash of latest commit>
What can I do ... update files without conflicts (like hg up -C)
When you do a git pull
, you bring in the changes to all the files from the remote branch. Usually you would not want to update only files which have no conflicts. Git is a workspace-based version control system, as opposed to something like SVN, which is a file-based VCS.
If you really want to try doing a git pull
and then update only files which are not in conflict, then you can use the following command to identify which files have conflicts:
git diff --name-only --diff-filter=U
Then for each file in the list, you can do a git reset
on it:
git checkout -- filename_in_conflict