Git问题备忘

更新本地库

在LeetCode上,每做完一道题目,为方便后续回顾,同步远程Github。

1
2
3
git add 需要同步的文件
git commit -m "备注"
git push -u origin master

远程仓库与本地仓库冲突

由于在远程仓库创建过新文件,导致与本地仓库版本冲突无法合并:

1
2
3
4
5
6
7
8
$ git push origin master
To github.com:sunflowerJY/LeetCode.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:sunflowerJY/LeetCode.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

解决方案:  
http://www.cnblogs.com/daemon369/p/3204646.html