04. 多地办公

1. 对远程仓库进行重命名

  git remote add my_design https://github.com/...                   //这个地址是项目的git页面 clone with http的地址,my_design是对这个地址的别名

2. 推送代码到远程

  git push -u my_design 分支名称

3. 参与项目,首次开发,需要克隆远程仓库

  git clone 远程仓库地址

  注意:远程仓库克隆后,使用<git branch>时通常只会显示master分支,需要使用<git checkout 分支名>进行分支切换。

  比如有两个分支:master 和 develop,通常master作为主分支不要在其上直接开发,而是要切换到develop进行开发

  git checkout develop

  如果有必要,需要先从master分支中获得最新的稳定代码,仅执行一次

  git merge master

4. 在本地进行开发,比如写了源代码文件 operation.sv,则需要先在本地进行提交,再推送到远程仓库。

  git add .

  git commit -m "complete the operation function"

  git push -u my_design develop

5. 换了办公地点(首次办公用clone,非首次用pull),要从远程仓库获取最新的代码

  切换到develop分支后,获取最新的代码

  git checkout develop

  git pull my_design develop

  又写了一个文件,shift.sv,则需要先在本地进行提交,再推送到远程仓库。

  git add .

  git commit -m "add shift function"

  git push -u my_design develop

6. 开发完毕上线

  dev合并到master,master上线

  git checkout master

  git merge develop

  git push my_design master

  上线的版本,此时master和develop代码是相同的,所以最好是都进行上线更新

  git checkout develop

  git merge master   //如果有多个人开发,这一步很有必要

  git push my_design develop    

原文地址:https://www.cnblogs.com/hilnx/p/14893676.html