Skip to content

Instantly share code, notes, and snippets.

@imyjimmy
Created April 24, 2011 06:49
Show Gist options
  • Select an option

  • Save imyjimmy/939380 to your computer and use it in GitHub Desktop.

Select an option

Save imyjimmy/939380 to your computer and use it in GitHub Desktop.
git conflict resolution example
Jimmy-Zhangs-iMac:Othello imyjimmy$ git pull
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
From github.com:imyjimmy/Othello
8d19685..f18ef73 master -> origin/master
Updating 8d19685..f18ef73
error: Your local changes to the following files would be overwritten by merge:
Board.java
Player.java
Please, commit your changes or stash them before you can merge.
Aborting
Jimmy-Zhangs-iMac:Othello imyjimmy$ git status
# On branch master
# Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: Board.java
# modified: BoardTester.java
# modified: Player.java
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .classpath
# .project
# Board.class
# Board2.java
# BoardTester.class
# HeuristicStateEval.class
# Player.class
# Position.class
no changes added to commit (use "git add" and/or "git commit -a")
Jimmy-Zhangs-iMac:Othello imyjimmy$ git add Board.java
Jimmy-Zhangs-iMac:Othello imyjimmy$ git add BoardTester.java
Jimmy-Zhangs-iMac:Othello imyjimmy$ git add Player.java
Jimmy-Zhangs-iMac:Othello imyjimmy$ git commit -m "pre-pull conflict commit"
[master 8e88c29] pre-pull conflict commit
Committer: Jimmy Zhang <imyjimmy@Jimmy-Zhangs-iMac.local>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
git config --global user.email you@example.com
If the identity used for this commit is wrong, you can fix it with:
git commit --amend --author='Your Name <you@example.com>'
3 files changed, 63 insertions(+), 62 deletions(-)
Jimmy-Zhangs-iMac:Othello imyjimmy$ git pull
Auto-merging Board.java
Auto-merging Player.java
CONFLICT (content): Merge conflict in Player.java
Automatic merge failed; fix conflicts and then commit the result.
Jimmy-Zhangs-iMac:Othello imyjimmy$ vim Player.java
Jimmy-Zhangs-iMac:Othello imyjimmy$ git add Player.java
Jimmy-Zhangs-iMac:Othello imyjimmy$ git status
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 1 and 1 different commit(s) each, respectively.
#
# Changes to be committed:
#
# modified: Board.java
# modified: Player.java
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .classpath
# .project
# Board.class
# Board2.java
# BoardTester.class
# HeuristicStateEval.class
# Player.class
# Position.class
Jimmy-Zhangs-iMac:Othello imyjimmy$ git commit -m "merge conflict commit"
[master 36b7a6a] merge conflict commit
Committer: Jimmy Zhang <imyjimmy@Jimmy-Zhangs-iMac.local>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
git config --global user.email you@example.com
If the identity used for this commit is wrong, you can fix it with:
git commit --amend --author='Your Name <you@example.com>'
Jimmy-Zhangs-iMac:Othello imyjimmy$ git push
Counting objects: 16, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (9/9), 1.51 KiB, done.
Total 9 (delta 5), reused 0 (delta 0)
To git@github.com:imyjimmy/Othello.git
f18ef73..36b7a6a master -> master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment