#Git 问题解决
##The current branch master has no upstream branch.
1
2
3
4
5
➜ NoteEasy git:(master) git push master
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream master master
- 解决方法:
- 首次将命令改为
1
2
3
4
5
6
7
8
9
➜ NoteEasy git:(master) git push -u master master
Counting objects: 10, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (10/10), 6.30 KiB | 644.00 KiB/s, done.
Total 10 (delta 0), reused 0 (delta 0)
To github.com:MetaNetworks/NoteEasy-FrontMatter_Generator.git
a340e2e..48c4db9 master -> master
Branch 'master' set up to track remote branch 'master' from 'master'.
##Updates were rejected because the tip of your current branch is behind
1
2
3
4
5
6
7
8
➜ NoteEasy git:(master) ✗ git push -u master
To github.com:MetaNetworks/NoteEasy-FrontMatter_Generator.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:MetaNetworks/NoteEasy-FrontMatter_Generator.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.
-
原因:本地仓库的最后一次commit与远程仓库的最后一次commit不一样(多人分工合作或者一次性commit多次容易出现这种情况)
-
解决:
- 使用强制push,远程丢失
git push -u origin master -f
- 先pull远程端到电脑,再push回
git pull
git push ...
- 如果不想merge,可以创建一个分支
git branch [new branch name]
git push -u origin [new branch name]
##The following untracked working tree files would be overwritten by merge
1
overwritten by merge
-
原因:同名文件存在差异
-
解决:先保存工作状态,pull下来,再stash pop出来
-
1 2 3
git stash git pull git stash pop
-