顯示具有 git 標籤的文章。 顯示所有文章
顯示具有 git 標籤的文章。 顯示所有文章

2013年6月17日 星期一

上傳tag到遠端的repo

上傳標籤到遠端

git push 並不會把標籤上傳到遠端,所以必須透過底下才行
git push origin v1.5
Counting objects: 50, done.
Compressing objects: 100% (38/38), done.
Writing objects: 100% (44/44)4.56 KiB, done.
Total 44 (delta 18), reused 8 (delta 1)
To git@github.com:schacon/simplegit.git
* [new tag]         v1.5 -> v1.5
如果在本機端很多標籤,利用 –tags 一次上傳上去
git push origin --tags
Counting objects: 50, done.
Compressing objects: 100% (38/38), done.
Writing objects: 100% (44/44)4.56 KiB, done.
Total 44 (delta 18), reused 8 (delta 1)
To git@github.com:schacon/simplegit.git
 * [new tag]         v0.1 -> v0.1
 * [new tag]         v1.2 -> v1.2
 * [new tag]         v1.4 -> v1.4
 * [new tag]         v1.4-lw -> v1.4-lw
 * [new tag]         v1.5 -> v1.5


http://blog.wu-boy.com/2010/11/git-%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6-%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%E6%A8%99%E7%B1%A4tag/

2013年5月1日 星期三

git checkout




Git checkout 切換 branch

git checkout branch-name # 切換到 branch-name
git checkout master # 切換到 master
git checkout -b new-branch master # 從 master 建立新的 new-branch, 並同時切換過去 new-branch
git checkout -b newbranch # 由現在的環境為基礎, 建立新的 branch
git checkout -b newbranch origin # 於 origin 的基礎, 建立新的 branch
git checkout filename # 還原檔案到 Repository 狀態
git checkout HEAD . # 將所有檔案都 checkout 出來(最後一次 commit 的版本), 注意, 若有修改的檔案都會被還原到上一版. (git checkout -f 亦可)
git checkout xxxx . # 將所有檔案都 checkout 出來(xxxx commit 的版本, xxxx 是 commit 的編號前四碼), 注意, 若有修改的檔案都會被還原到上一版.
git checkout -- * # 恢復到上一次 Commit 的狀態(* 改成檔名, 就可以只恢復那個檔案)




Reference
1. http://www.cnblogs.com/craftor/archive/2012/11/04/2754147.html
2. http://blog.longwin.com.tw/2009/05/git-learn-initial-command-2009/

2013年4月29日 星期一

git clone / fetch / pull


Clone:
會把遠端的repo整個專案抓下來,放在目前路徑下的新目錄中。(所以不需要先把新目錄建立成Repo,就可以整包抓下來,隨包附上.git目錄)
Pull = Fetch + Merge : 會把遠端的repo整個專案抓下來,跟你目前所在的Repo及所用的Branch作合併(Merge),此指令等同Fetch+Merge。

Fetch
:

會把遠端的repo整個專案抓下來,但不跟你目前所用的branch合併,而是放在本地中的另一個Branch(remoteBranch)。
http://www.mrmu.com.tw/2011/05/06/git-using-dropbox-as-server/


http://kevyu.blogspot.tw/2011/08/git-push.html

git remote篇


Git remote 維護遠端檔案

  • git remote
  • git remote add new-branch http://git.example.com.tw/project.git # 增加遠端 Repository 的 branch(origin -> project)
  • git remote show # 秀出現在有多少 Repository
  • git remote rm new-branch # 刪掉遠端的new-branch
  • git remote update # 更新所有 Repository branch
  • git branch -r # 列出所有Remote Repository branch
  • git remote show <branch> 

Reference

2013年4月26日 星期五

git bisect(對分)


git bisect就是利用binary search的方式來搜尋造成bug的commit是在哪裡。
-- find by binary search the change that introduced a bug.


git bisect <sub-command> <options>

2013年3月14日 星期四

pull requests



https://help.github.com/articles/using-pull-requests

pull requests

pull有"招致"、"吸引"的意思

pull requests就是讓你告訴參與該專案的其他人你將會改變那些部分然後push回GitHub repo.一旦pull request送出,有興趣的人就可以檢閱有哪些部分有改變過,然後討論是否要進行更進一步的修改。

Pull requests let you tell others about changes you've pushed to a GitHub repository. Once a pull request is sent, interested parties can review the set of changes, discuss potential modifications, and even push follow-up commits if necessary.

一般的協同開發模式( Collaborative Development Models )可以分成兩種:

1. Fork & Pull

--  lets anyone fork an existing repository and push changes to their personal fork without requiring access be granted to the source repository.
--  The changes must then be pulled into the source repository by the project maintainer.
--  This model reduces the amount of friction for new contributors and is popular with open source projects because it allows people to work independently without upfront coordination. 


2. Shared Repository Model

--  more prevalent with small teams and organizations collaborating on private projects
--  Everyone is granted push access to a single shared repository and topic branches are used to isolate changes.



Reference
http://edwardinaction.blogspot.tw/2012/05/github-pull-requests.html
http://www.worldhello.net/gotgithub/04-work-with-others/010-fork-and-pull.html
http://tw.polydice.com/2012/05/08/github-pull-requests/



2013年3月3日 星期日

git的物件型態

在物件儲存中,git僅使用了四種型態的物件:

1.  BLOBs, Binary Large OBjects (二進位的大型物件):
   
 檔案的每個版本都是由Blob所組成的。而這個詞彙被廣泛使用在資訊界,泛指可以儲存任何型態資料的檔案變數,而且使用BLOBs的程式是並不會在意其內部結構的,因為BLOB型態的資料不易理解,因為它並沒有包含任何關於檔案的資訊,甚至檔案名稱都沒有。

2.  Tree:
     樹狀物件代表一個階層的目錄資訊。它記錄著
     I.  BLOB辨識碼
    II.  BLOB的路徑名稱
   III.  以及在這個目錄中所有檔案的一些資訊。

     樹狀物件本身也可以遞迴的參考其他子樹物件,然後建立出完整的檔案以及子目錄的階層架構。


3.  Commits(送交): 
---  送交物件擁有每次容器更動時的所有資訊,包含了作者、送交者、送交的時間以及歷史紀錄訊息等。

---  每次的送交都會指向一個樹狀物件,這個物件紀錄了送交當下該容器的狀態。(除了最一開始的送交沒有"父送交物件",而大多數的送交都會有一個"父送交物件")


4.  Tags(標籤):
     
標籤物件將人類易讀的名字賦予給特定物件(通常是Commits送交物件)


git的tag(標籤)

git tag的基礎概念


git目前僅有實作一種標籤物件,但它卻有兩種型態:


1. Lightweight Tag(輕量標籤):
   
輕量標籤參照至一個"送交物件",且通常是該容器所私有的標籤(?!),這種標籤不會在物件儲存上建立永久物件。 
2. Annotated Tag(標示標籤):
   
標示標籤則會真實的建立一個物件,而該物件裡面會包含你所提供的訊息,則該訊息可以根據RFC-4880使用GnuPG金鑰來簽屬"數位簽章"。



Git將Lightweight Tag以及Annotated



git tag的使用



http://blog.wu-boy.com/2010/11/git-%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6-%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%E6%A8%99%E7%B1%A4tag/

http://gitbook.liuhui998.com/3_7.html

git所維護的特殊符號參照



  • git當中所有的符號參照都可以使用 git symbolic-ref 指令來管理
  • git因為某些特殊目的所以維護了一些特別的符號參照,它們可以被用在任何可以使用"送交(commit)"的地方:
    1.  HEAD   
         HEAD永遠指向目前分支上最新的commit(送交)。當你修改分支時,HEAD就會被更新,指向該分支最新的commit(送交)。


    2.  ORIG_HEAD   
         在執行某些動作例如"merge(合併)"或是"reset(重設)"時,在執行之前,會將前一個版本的HEAD紀錄在ORIG_HEAD。
        可以使用ORIG_HEAD來回復至前一個版本或者是進行比較


    3.  FETCH_HEAD
       
    當使用"遠端容器(Remote Repo)"時,git fetch指令會記錄從 .git/FETCH_HEAD檔案中所有分支的HEAD。
         FETCH_HEAD就是你抓取的上一個分支的HEAD,並且僅在抓取的指令之後有效。使用這個符號參照,你可以找到你使用 git fetch指令所抓取的HEAD,並且不用指定分支名稱。


    4.  MERGE_HEAD
        當合併在執行時,另一個分支的HEAD會被暫時的紀錄在MERGE_HEAD之中。
        換句話說:  MERGE_HEAD會指向要被合併到目前HEAD的送交物件。


    [Note]
           雖然可以使用上述的符號參照來建立自己的分支,但不建議這麼做!!

git中的檔案分類



Git將"檔案"分成三大類:
  1. 被追蹤(tracked): 
    被追蹤的檔案代表它已經在容器或是已經在索引中準備好了。
    EX: 要新增一個檔名叫做somefile的檔案此管理容器中,執行git add somefile即可。
  2. 被忽略(ignored):
    被忽略的檔案必須設定為"隱藏的"或是"被忽略的",就算檔案本身在你所管理的容器中。
    Git會維護一張被忽略的檔案清單(.gitignore),可以在你管理的容器內自行配置要忽略的檔案。
  3. 不被追蹤(untracked):
    不屬於前述兩個類別的檔案就稱之為"不被追蹤"的檔案。