git 使用笔记

Commonly used instructions

rebase & merge & branch default

choose rebase or merge???
rebase or merge or branch default
git rebase 和git merge 做的事其实是一样的。它们都被设计来将一个分支的更改并入另一个分支,只不过方式有些不同。

  • 如果你想要一个干净的、线性的提交历史,没有不必要的合并提交,你应该使用 git rebase 而不是 git merge 来并入其他分支上的更改。
  • 如果你想要保存项目完整的历史,并且避免重写公共分支上的 commit, 你可以使用 git merge。两种选项都很好用,但至少你现在多了 git rebase 这个选择。

FBI Warning: 绝不要在公共的分支上使用rebase!
运行 git rebase 之前,一定要搞清楚有没有别人正在这个分支上工作,如果有,就不能rebase.

交互式rebase : git rebase -i

  • Merge: The result is identical with that of running git fetch ; git merge or git pull.
  • Rebase: The result is identical with that of running git fetch ; git rebase or git pull --rebase.
  • Branch Default: This option is to choose the default command for the branch applied. The default command is specified in the branch.<name> section of the .git/config configuration file.

stash & shelve

当手头工作没有完成时(很杂乱,你又不想提交),先把工作现场$ git stash一下,然后去修复bug,修复后,再$git stash pop(恢复的同时把stash内容也删了),回到工作现场。
你可以多次stash,恢复的时候,先用git stash list查看,然后恢复指定的stash,用命令:
$ git stash apply stash@{0}
shelve是pycharm中才有,不是git语句

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值