创建新的repo
有时我们只是希望在本地管理好自己的代码,并不需要在云端有一个repo,这个时候可以如下方法使用git
- Create a directory to contain the project.
- Go into the new directory.
- Type git init.
- Write some code.
- Type git add to add the files .
- Type git commit.
git cherry-pick
git cherry-pick
是将指定的提交应用于其他分支。
git cherry-pick <commit Hash>
例:将feature分之的f应用到master
cherry pick操作前
git checkout master
git cherry-pick f
经过操作则变为
git cherry-pick
命令的参数,也可以是分支名称
git cherry-pick feature
cherry pick
支持一次转移多个提交
git cherry-pick <HashA> <HashB>
git cherry-pick A..B #转移一系列的连续提交,但是提交A不会包含再Cherry pick中
git cherry-pick A^..B #提交A也包含在cherry pick中
解决代码冲突
—continue
用户解决代码冲突后,第一步将修改的文件加入暂存区(git add .),第二步使用git cherry-pick --continue
让cherry pick过程继续执行。
—abort
发生代码冲突后,放弃合并,回到操作以前的样子
—quit
发生代码冲突后,退出Cherry pick,但是不会倒操作前的样子
参考资料
https://kbroman.org/github_tutorial/pages/init.html
https://www.ruanyifeng.com/blog/2020/04/git-cherry-pick.html