Git
pipeline
Check Last Commit Status
Show last one commit
Show last two commits
Add Remote repo
In Terminal, add the URL for the remote repository where your local repository will be pushed.
set the new remote
"gitlab" << remote repo name
Verifies the new remote URL
Push the changes in your local repository to GitHub
更新從 GitHub 上 fork 出來的 repository (或是同步兩個不同 server 端的 repository)
大致講一下流程 … 操作必須是在自己 local 端做 (希望以後 GitHub 可以推出按一個鈕就幫我去同步到最新XD),做法是把 fork 出來的 repository 在本地更新後、再把 repository 給 push 出去!會需要用到 git 的 branch, remote, pull, push 觀念。
接下來的操作環境是你已經把你 fork 出來的 repository 給 clone 到自己的電腦上了, clone 好之後請切換到對應的資料夾底下,然後就可以開始使用 git 做操作了。
第一次操作時我們要加入一個遠端的 remote 當作更新來源,如果要比較是否有加入成功的話可以在操作前後先看狀態:
$ git remote -v
我們用下面這個命令來加入遠端的 repository,在這邊的情境也就是比較新的、上游的 repository
upstream 是 remote name、可以自己取名,不要重複就好,但後面我都用會 upstream 做示範
而後面那串網址是 repository 位置:
$ git remote add upstream https://github.com/otheruser/repo.git
如果再看一次現有的remote端應該會發現多了兩組 upstream (fetch & push):
$ git remote -v
origin https://github.com/user/repo.git (fetch)
origin https://github.com/user/repo.git (push)
upstream https://github.com/otheruser/repo.git (fetch)
upstream https://github.com/otheruser/repo.git (push)
有了遠端的來源後我們就可以開始做更新了
假如我要做更新的的 branch 是 master 的話就先切到 master branch:
$ git checkout master
接著把 upstream 的 master 更新給拉進來
$ git pull upstream master
如果你的 master branch 有自己的 commit, 也可以用 rebase 來避免不必要的 merge 操作:
$ git pull --rebase upstream master
如果沒有發生衝突的話這樣應該就完成了本地的更新,再把更新後的 branch push 出去就行了
$ git push origin master
這時再回去看看你的 repository 頁面,應該會發現已經同步到最新的狀態了!
overwrite a branch on another branch
Last updated