Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Thursday, January 11, 2018

設定 go get 存取 github 的協定

在防火牆後執行 go get 或是 go installgithub.com 取得套件時,發現 go 會使用 git:// 去存取。因為網路管制的關係,無法連到 TCP 22 埠,所以就連線失敗無法取得套件。

使用下面的命令設定 git 針對特定目標的連線方式後,就可以順利取得套件了:

git config --global url."https://github.com/".insteadOf git@github.com:

Monday, April 17, 2017

變更 git 歷史記錄後必須要做的事情

這幾天因為之前沒有注意到作者欄沒有設定好,結果留了一些不正確的作者名稱到 repository 的 commit 裡。

在 Github 的 Changing author info 說明中有提到,可以使用下面這個 script 來修改 commit 中的欄位。

但是沒有講到如果遠端的 repository 有設定了 tracking branch 到被修改影響到的 branch 上的話要怎麼辦,然後我不小心就踩到了,多了幾個內含有之前寫錯了作者的 commit 的支線出來。

模索半天之後,有點苦的做了 git rebase -i 最早的沒問題的版本 把有錯的 commit 都刪掉後,重新 git push --force --tags origin 'refs/heads/*' 到污染到的遠端檔案庫上,還好數量不多。

然後,有追蹤被修改分支的其他檔案庫要執行 git fetchgit checkout -B master (假設 tracking branch 是 master) 來更新本地端的檔案庫。這邊的 -B 是建立或更新 branch 的意思,單純 -b 的話就只能建立,在這邊需要更新,因此要使用 -B 選項。

Monday, December 21, 2015

在 git repository 中取出特定 tag 會用到的指令

因為某種原因,所以不能單純的就用最新的版本之類的,得要一段時間固定在某個版本上。

git tag -l

將所有已定義的 tag 列出。

git checkout tags/TAG_NAME

檢出特定 tag 版本檔案。

Wednesday, April 22, 2009

Git 的 push

之前是用 Subversion 來作版本控制,可是不是總是可以連到中央伺服器上,所以最近移轉到 Git 上。

Git 的 push 不會去改變 work copy 的內容,而且 HEAD 也不會前進到最新的 commit 上,一整個跟 Subversion 線性的歷史記錄不太一樣。

如果發生了 push 進附有 work copy 的 repository 的事情,更新 work copy 就得要先用 git log 先把最近一個 remote commit 的 commit ID 找出來,然後再用 git reset %COMMIT-ID% 來把 HEAD 設定過去,最後用 git checkout . 來把 work copy 更新。

看來還是要準備一個 bare repository 才行,也就是每個人要有 public repository 跟 private repository 兩個 repository ... 感覺實在挺浪費的。

建立 bare repository:

$ mkdir project.git
$ cd project.git
$ git init --bare

將現有位於 /home/me/project 的 repository 複製成位於 /home/me/repo/project.git 的 bare repository:

$ cd /home/me/repo
$ git clone --bare /home/me/project

把 remote repository 設定補進 private repository 中:

$ git remote add origin /home/me/repo/project.git
$ git config branch.master.remote origin
$ git config branch.master.merge refs/heads/master