问题:
Git冲突:Please commit your changes or stash them before you merge
原因:git pull要更新代码时 本地代码修改了 需要先commit 或 stash 但是不想commit 就可以stash 保证本地工作区干净
Stage Changes相当于git add xxx。可以多选,批量地将变更文件放入暂存区,比git add .好用。
Stash Changes相当于git stash,将选中的变更文件“藏起来”,然后当前分支就“干净”了,可以切换到其他分支去了。
那么藏起来的内容怎么恢复呢?
回到刚才执行git stash的分支,执行git stash pop,就会将最近一次藏起来的内容提取出来了。(注:如果stash了好几次,要提取其中某一次的内容,可以使用````git stash apply``命令)
可能会出现如图错误The RSA host key for [artifactory-lfs.l1sw.dyn.nesc.nokia.net]:8282 has changed
是生成的known_hosts中的RSA发生了变化
git fetch
代码更新 git fetch
git pull
然后更新子模块git submodule update --init
解决办法
删除文件 rm /home/zhsu/.ssh/known_hosts
然后操作:
git checkout master (Note: git checkout command is excuted when git workspace is clean. In other word, there must no modify and staged file in your repository when you excute “git checkout”)
if there alredy have new commit that you commit to master branch:
option 1: git fetch origin; git rebase origin/master
option 2: git pull --rebase
else if only want to sync your master branch with origin/master
git fetch origin; git reset --hard origin/master
git submodule update --init --recursive --jobs=16
https://zhuanlan.zhihu.com/p/34197548
总结:
下游分支更新上游分支内容的时候使用 rebase
上游分支合并下游分支内容的时候使用 merge
更新当前分支的内容时一定要使用 --rebase 参数
git pull --rebase
当本地代码提交后且更新了新代码后(新代码覆盖了本地 同步了master时) 想要自己原来提交状态的代码
git fetch "https://xxx@xxx.com/A/B" refs/changes/28/4473628/4 && git cherry-pick FETCH_HEAD
想对commit信息回退修改 但是不对代码的改动修改 保留该版本代码的修改
在提交代码的时候,commit之后,然后我又在工作区添加了东西,这时候突然发现,上一次的commit有错误的文件,需要重新修改,但是我添加的东西友不想丢失,而且我想修改上一次的提交,这时候可进行git reset --soft 版本号
作用:用于版本的回退,只进行对commit操作的回退,不影响工作区的文件。
git log 查看commit 版本号
git reset --soft
https://blog.csdn.net/yangfengjueqi/article/details/61668381?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-61668381-blog-120782767.pc_relevant_multi_platform_whitelistv1_exp2&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-61668381-blog-120782767.pc_relevant_multi_platform_whitelistv1_exp2&utm_relevant_index=1