git分支相关命令

<name> : 分支名

查看分支:git branch

功能命令
创建分支git branch <name>
切换分支git checkout <name>
创建+切换分支git checkout -b <name>
合并某分支到当前分支git merge <name>
删除分支git branch -d <name>
查看分支git branch
查看远程分支git branch -a
查看当前分支最后一次修改的信息git show
查看当前分支最后一次修改信息简化版git show --stat

.

  • 关于有时pull没有跟踪信息
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> c

原因:
这是说你当前的分支没有跟踪远程库的某个分支,也就是他们之间没有建立联系。
如果需要pull的话,需要我们自己为他们建立联系。
假如现在远程仓库有个分支a ,你本地有个分支叫做c ,但是远程没有c分支。
然后直接git pull,就会出现这种情况。

解决方法:
现在是c分支
要和远程分支a建立联系

git branch --set-upstream-to=origin/a
git pull

.

新创建的分支如果push时显示:

fatal: The current branch feature_v1.3.11_look-detail has no upstream branch.
To push the current branch and set the remote as upstream, use

git push --set-upstream origin <name>

那么就照着他说的执行git push --set-upstream origin <name> 这句就好了

需要注意的事情:
假如现在在分支A,然后修改A以后,直接切换到分支B,
有时会提示:Please commit your changes or stash them before you switch branches. Aborting说名还没有commit 。
直接:
git add .
git commit
提交就行了
我还碰到过一种情况,就是没有commit也能切换
如果是这样的话,在A中修改的内容会带到B分支来。但其实不是真的带到B来了,再切换回A分支,提交一下,然后A带到B的内容就没了,B分支就恢复正常了。

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值