赞
踩
首先,本地文件之前是svn管理,现在直接换成git,远程仓库已经有新代码和master分支
$ git stash -a -m 'svn'
You do not have the initial commit yet
0@DESKTOP-2RBCSD9 MINGW64 /d/newFrontProject (master)
$ git commit
[master (root-commit) 9ddb6f8] nit svn (查看状态)$ git status
On branch master
nothing to commit, working tree clean
再次查看git branch -a并且拉取$ git pull origin master,发现出现merge conflict;(master|REBASE 1/1)
$ git status
interactive rebase in progress; onto 1245feb
查看所在分支会发现是rebase状态,也就不在master分支上 :
(master|REBASE 1/1)
$ git branch
* (no branch, rebasing master)
master
0@DESKTOP-2RBCSD9 MINGW64 /d/newFrontProject/DossierSite/WebSiteForManager (master|REBASE 1/1)
$ git reset --hard HEAD(不想直接丢弃本地差异文件可以再次使用前面步骤5进行贮藏)
HEAD is now at 1245feb Merge #1 into master from dev1
使用rebase命令:(master|REBASE 1/1)
$ git rebase --continue
Successfully rebased and updated refs/heads/master.
再次拉取master分支,此时状态正常,拉取成功:
(master)
$ git pull origin master --rebase
From https://
* branch master -> FETCH_HEAD
Already up to date.
查看所在分支已正常:(master)
$ git branch
* master (*表示目前在这个分支上)
此时直接git pull 拉取代码会提示没有关联远程分支:
(master)
$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to rebase against.
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> master
使用命令:(master)
$ git branch --set-upstream-to=origin/master master
提示 Branch 'master' set up to track remote branch 'master' from 'origin'.
使用 git pull正常,不需要指定分支
Already up to date.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。