一、如何将远程修改同步到个人fork仓库
1、添加 远程上游仓库
// git remote add <remote-name> <url>
git remote add upstream https://github.com/Soft/someproject.git //远程主干仓库
git remote add origin https://github.com/Demodevelop/someproject.git //远程仓库的fork 仓库
需要将远程仓库的修改同步到fork 仓库,保持个人仓库同步,
2、切换到fork 本地仓库分支、
git checkout origin (本地分支的名字)
3、从远程仓库拉取代码
git pull upstream master
4、将拉取到本地的代码 push 到个人fork 仓库
git push origin
5、 提交个人修改代码
git add test.c
git commit -m "add new file "
git push origin
二、修改远程提交信息的方法
git rebase -i HEAD~n //最近几个提交
由远及近列出了我们期望处理的三个提交,前面pick代表的默认使用该提交commit,我们现在可以按i进入编辑模式,修改该字段值,值可以如图中描述,经常使用的如下:
-
pick:简写p,启用该commit;
-
reword:简写r,使用该commit,但是修改提交信息,修改后可以继续编辑后面的提交信息;
-
edit:简写e,使用commit,停止合并该commit;
-
sq