➜ mygit git:(master) ls README.md test.txt ➜ mygit git:(master) cat test.txt hello world add second line add a thrid line ➜ mygit git:(master) cat README.md ## Git示例项目
➜ mygit2 git:(master) git push To github.com:sail-y/git_demo.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'git@github.com:sail-y/git_demo.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards'in'git push --help'for details. ➜ mygit2 git:(master) git pull remote: Counting objects: 3, done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done. From github.com:sail-y/git_demo bb880c1..f162a21 master -> origin/master Auto-merging hello.txt CONFLICT (content): Merge conflict in hello.txt Automatic merge failed; fix conflicts and then commit the result.
➜ mygit2 git:(master) ✗ vi hello.txt ➜ mygit2 git:(master) ✗ git status On branch master Your branch and 'origin/master' have diverged, and have 1 and 1 different commits each, respectively. (use "git pull" to merge the remote branch into yours) You have unmerged paths. (fix conflicts and run "git commit") (use "git merge --abort" to abort the merge)
Unmerged paths: (use "git add <file>..." to mark resolution)
both modified: hello.txt
no changes added to commit (use "git add" and/or "git commit -a") ➜ mygit2 git:(master) ✗ git add hello.txt ➜ mygit2 git:(master) git status On branch master Your branch and 'origin/master' have diverged, and have 1 and 1 different commits each, respectively. (use "git pull" to merge the remote branch into yours) All conflicts fixed but you are still merging. (use "git commit" to conclude merge)