git切换分支


今天同事问我她的报错了,我看了一下,是分支没有指向远程仓库对应的分支;


报错如下;
$ git pull
There 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> mymaster

 报错背景:1

新建的分支:(git branch mymaster);这样创建了一个mymaser的分支;

然后git checkout mymaser;这样就切换到了mymaser这个仓库上了

 

 

然后就报了上面的错;所以这时候要执行下面这段代码
git branch --set-upstream-to=origin/master mymaser
其中origin/master是远程仓库的分支;而mymaser是你自己的分支,
不管push还是pull的时候都要使mymaser指向远程仓库的分支才可以;

如果不执行上面的代码,那么你每次pull或者push的时候都要执行 
git pull origin/master 指向远程分支;

git push origin/master 指向远程分支;

执行之后的话就直接 git pull或者 push就可以;

当然你自己的分支不一定是mymaser;执行git branch 看一下几个分支;都让它指向远程分支
ok!!!!!!!!!!!

 

微信公众号:

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM