Pragmatic Version Control Using Git(筆記)

來源:互聯網
上載者:User

標籤:git   linux   svn   chromium   tag   

Pragmatic Version Control Using Git跳轉到: 導航, 搜尋
  1. git config --global user.name "Travis Swicegood"
  2. git config --global user.email "[email protected]"
  3. git config --global --list
  4. git config --global color.ui "auto"
  5. cd mysite && git init
  6. git commit -m "add in hello world HTML" //SHA1雜湊
  7. git branch RB_1.0 master //建立分支
  8. git checkout RB_1.0 //??似乎沒有到另外一個目錄??我個人懷疑這樣做的效率(不過,也許Linux的ext3檔案連結處理起來比較方便?)
  9. git tag 1.0 RB_1.0 //tag:標記一個特殊的時間點。。。
  10. rebase:合并分支上的修改到主線
    1. git checkout master
    2. git rebase RB_1.0 //試圖replay所有變更。。。
    3. git branch -d RB_1.0 //一旦合并到主線,則可以刪除掉分支
    4. 但是,刪除了分支後怎麼恢複呢?可以從tag:git branch RB_1.0.1 1.0 這隻是為了fix特定狀態發布的補丁
  11. git log --pretty=oneline
  12. git archive --format=tar --prefix=mysite-1.0/ 1.0 | gzip > mysite-1.0.tar.gz
  13. git clone git://github.com/tswicegood/mysite.git mysite-remote //遠程倉庫
  14. git add -i //互動模式?
  15. git add -p //匯出patch檔案(這個比較贊,其他svn、hg都沒見過這麼方便的)
  16. 顯示差異 (1)what‘s in your working tree, (2)what‘s staged and ready to be committed, and (3)what‘s in your repository:git diff |--cached|HEAD
  17. add .*.swp to the .gitignore ...
  18. 分支重新命名:git branch -m old new
  19. One of the hardest parts of branches is figuring out when to create a branch. It’s an art, not a science
    1. Experimental changes
    2. New features
    3. Bug fixes
  20. checkout -b(建立新分支同時checkout)
  21. Merging:(注意,merge後還需要提交!)
    1. Straight merge:合并2個分支:在主線上執行git merge branch即可
    2. Squashed commits:壓縮分支上的多個提交,轉換為另一個上的單個提交(?),git merge --squash branch
    3. Cherry-picking:直接將一個分支上的一個提交送到另一個分支上(這個太酷了,mecurial好象不支援~~)git cherry-pick 321d76f(分支上的commit編號)
      1. -n選項:to do the merge but stop before creating a commit
  22. git reset --hard HEAD^
  23. 查看曆史:git log(可以追加額外的參數指定範圍,略)
  24. 追蹤特定檔案中行的變更情況:git blame -L 12,13 hello.html //注意:可以12,+2或13,-2描述(微型文法~~)
  25. revert:重寫曆史... Break one commit into multiple commits??
  26. git fetch:保持與遠程倉庫up-to-date
  27. git branch -r
  28. git push
  29. git diff:查看2個版本之間的修改情況(顯示為一個差分提交,這個功能Mercurial/Hg是沒有的,SVN可以做出比較),而git log將顯示所有提交的曆史
  30. Beyond the Basics(略):
    1. git gc:Compacting your repository history
    2. git archive:Exporting your repository
    3. git rebase:Rebasing a branch‘s history against its parent
    4. Using the reflog to fix your repository
    5. Bisecting your repository to find what change introduced a bug 

Pragmatic Version Control Using Git(筆記)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.