1.情形一
剛來新公司,你開始有任務了
1).fork 項目地址
gitlab or github 進行fork操作
然後git clone fork地址
git clone upstream upstream_repository.git
添加 公司代碼庫的upstream
git remote add upstream upstream_repository.git
2).更新到最新代碼
git pull upstrem
3).新建一個分支開始開發
git checkout upstream/branchName git checkout -b branchName git merge upstream/branchName
4).開發完成,push項目併合併到qa分支待提測
git push
fork 項目發起merge request
結束啦,把merge request 提給測試
情形二
你需要部署一下項目代碼,但是你只能部署公司的代碼庫
git clone upstream_repository.git
git ls-remote upstream|grep mrid
git pull origin refs/merge-requests/153/head 上一步的內容
耶✌️
基本命令
1.upstream repository是你的上游倉庫,你沒有提交的權限
2.fork repository 是你fork的倉庫,所以你的權限很足。(圖形界面fork 操作)
git clone fork_repository.git
3.添加upstream 倉庫地址作爲upstream,
git add remote upstream upstream repository address
4.因爲fork的地址clone的時候會被添加 orgin,如下命令查看 會有2個地址
git remote -v
5.如何push fork repository
git push origin(origin 可省略)
6.如何push upstream (無法直接push,但是提交mr)
登錄fork 項目發起merge request
7. 如何同步upstream 的代碼
git pull upstream
8.如何合併upstream的代碼
git merge upstream/branchName
9. 來了一個需求 你創建了一個分支
git chekcout -b xxx
10.切換到upstream分支
git checkout upstream/develop