Git 的使用(记最近git踩的坑)
使用 git rebase 时遇到的问题(记最近git踩的坑)
首先,新建一个文件 test.js,新增一些内容,push到master
然后创建一个分支 test,修改 test.js 并提交到分支 test
接着,切换回 master,修改 test.js,创造冲突
再次切换到 test 分支,进行 git rebase,出现冲突,开始尝试解决
保留三条 message,按照提示 add,然后使用 git rebase --continue
然后,陷入死循环。。。。。。。。
- 经过多次测试 最终发现问题 —— git rebase 之后 commit 了。。。
- 但始终不知 git rebase xxx 与 git pull --rebase xxx 的区别,以后再补充
** 正确的打开方式:**
- 分支:xxx 上
- (xxx)git pull --rebase origin master
- if 冲突(会自动 merge)
- 修改冲突的地方
- (xxx)git add 修改的文件 (注意不要 commit,add 就行)
- (xxx)git rebase --continue
- (xxx)git push -u origin xxx
- (xxx)git checkout master (切换到 master)
- (master)git pull --rebase origin xxx (master 上 pull 后提交)
- (master)。。。。。。。
###git常用命令
- git status
- git diff
- git pull
- git pull --rebase
- git rebase
- git reset
- git log
- git reflog(查看所以git操作)
- git cherry-pick