问题一:
新建本地分支后将本地分支推送到远程库, 使用git pull 或者 git push 的时候报错
gitThere is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> merged0.9.6
是因为本地分支和远程分支没有建立联系 (使用git branch -vv 可以查看本地分支和远程分支的关联关系) .根据命令行提示只需要执行以下命令即可
git branch --set-upstream-to=origin/远程分支的名字 本地分支的名字
查看本地和远程仓库的所有分支
git branch -a
查看远程仓库的分支
git branch -r
问题二
再次git push ,出现
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/caizelin111/securitydemo'
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.
解决方案:
1、git pull origin master --allow-unrelated-histories //把远程仓库和本地同步,消除差异
2、重新add和commit相应文件
3、git push origin master
4、此时就能够上传成功了
本文介绍了在使用Git推送时遇到的两个常见问题及其解决方案。问题一是由于本地分支未与远程分支建立联系,解决方法是查看并关联本地与远程分支。问题二是推送时存在不兼容的历史记录,解决方案包括执行git pull with allow-unrelated-histories,重新add、commit文件,然后push到远程仓库。
1227

被折叠的 条评论
为什么被折叠?



