• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            流量統(tǒng)計(jì):
            Rixu Blog (日需博客)
            日需博客,每日必需來踩踩哦..
            posts - 108,comments - 54,trackbacks - 0

            1. 創(chuàng)建一個(gè)新的版本庫

            從一個(gè)壓縮包中創(chuàng)建:

            $ tar xzf project.tar.gz
            $ cd project
            $ git init #Initialized empty Git repository in .git/
            $ git add .
            $ git commit

            從遠(yuǎn)程版本庫創(chuàng)建:

            $ git clone git://example.com/pub/project.git
            $ cd project

            2. 管理分支

            $ git branch         # list all local branches in this repo
            $ git checkout test  # switch working directory to branch "test"
            $ git branch new     # create branch "new" starting at current HEAD
            $ git branch -d new  # delete branch "new"

            創(chuàng)建一個(gè)不以當(dāng)前的 HEAD 為起點(diǎn)的分支,用:

            $ git branch new test    # branch named "test"
            $ git branch new v2.6.15 # tag named v2.6.15
            $ git branch new HEAD^   # commit before the most recent
            $ git branch new HEAD^^  # commit before that
            $ git branch new test~10 # ten commits before tip of branch "test"

            創(chuàng)建并同時(shí)切換至新的分支:

            $ git checkout -b new v2.6.15

            更新和檢驗(yàn)從遠(yuǎn)程版本庫中克隆過來的分支:

            $ git fetch             # update
            $ git branch -r         # list
              origin/master
              origin/next
              ...
            $ git checkout -b masterwork origin/master

            從不同的版本庫中抓取分支,并給予一個(gè)在你的版本庫中新的分支名稱:

            $ git fetch git://example.com/project.git theirbranch:mybranch
            $ git fetch git://example.com/project.git v2.6.15:mybranch

            給你要定期地協(xié)同工作的版本庫制作一個(gè)列表:

            $ git remote add example git://example.com/project.git
            $ git remote                    # list remote repositories
            example
            origin
            $ git remote show example       # get details
            * remote example
              URL: git://example.com/project.git
              Tracked remote branches
                master
                next
                ...
            $ git fetch example             # update branches from example
            $ git branch -r                 # list all remote branches

            3. 勘查歷史

            $ gitk                      # visualize and browse history
            $ git log                   # list all commits
            $ git log src/              # ...modifying src/
            $ git log v2.6.15..v2.6.16  # ...in v2.6.16, not in v2.6.15
            $ git log master..test      # ...in branch test, not in branch master
            $ git log test..master      # ...in branch master, but not in test
            $ git log test...master     # ...in one branch, not in both
            $ git log -S'foo()'         # ...where difference contain "foo()"
            $ git log --since="2 weeks ago"
            $ git log -p                # show patches as well
            $ git show                  # most recent commit
            $ git diff v2.6.15..v2.6.16 # diff between two tagged versions
            $ git diff v2.6.15..HEAD    # diff with current head
            $ git grep "foo()"          # search working directory for "foo()"
            $ git grep v2.6.15 "foo()"  # search old tree for "foo()"
            $ git show v2.6.15:a.txt    # look at old version of a.txt

            查找撤退點(diǎn):

            $ git bisect start
            $ git bisect bad                # current version is bad
            $ git bisect good v2.6.13-rc2   # last known good revision
            Bisecting: 675 revisions left to test after this
                                            # test here, then:
            $ git bisect good               # if this revision is good, or
            $ git bisect bad                # if this revision is bad.
                                            # repeat until done.

            4. 制作變更

            配置 git

            vi ~/.gitconfig

            [user]
                name = Phoenix
                email = phoenixtoday@gmail.com
            [alias]
              co = checkout
              ci = commit -a
              st = status
              br = branch
              oneline = log --pretty=oneline --since='2 days ago'
              onelog = log -p -1
            [color]
              status = auto
              branch = auto
              ui = auto

            選擇這下次提交的時(shí)候要包含那些文件,接著制作交付:

            $ git add a.txt    # updated file
            $ git add b.txt    # new file
            $ git rm c.txt     # old file
            $ git commit

            或者是準(zhǔn)備提交和創(chuàng)建交付一步完成:

            $ git commit d.txt # use latest content only of d.txt
            $ git commit -a    # use latest content of all tracked files

            5. 合并

            $ git merge test   # merge branch "test" into the current branch
            $ git pull git://example.com/project.git master
                               # fetch and merge in remote branch
            $ git pull . test  # equivalent to git merge test

            6. 共享你的變更

            引入或者導(dǎo)出補(bǔ)丁:

            $ git format-patch origin..HEAD # format a patch for each commit
                                            # in HEAD but not in origin
            $ git am mbox # import patches from the mailbox "mbox"

            抓取一個(gè)不同的 git 版本庫的分支,并合并進(jìn)當(dāng)前分支:

            $ git pull git://example.com/project.git theirbranch

            在合并至當(dāng)前分支之前,將遠(yuǎn)程分支的變更保存為本地的分支:

            $ git pull git://example.com/project.git theirbranch:mybranch

            創(chuàng)建了本地分支的交付之后,用這些交付更新遠(yuǎn)程分支。

            $ git push ssh://example.com/project.git mybranch:theirbranch

            當(dāng)本地和遠(yuǎn)程分支都是叫 "test" 時(shí):

            $ git push ssh://example.com/project.git test

            對(duì)于經(jīng)常通訊的遠(yuǎn)程版本庫,有快捷命令的版本:

            $ git remote add example ssh://example.com/project.git
            $ git push example test

            7. 版本庫的維護(hù)

            檢查損壞:

            $ git fsck

            重新打包,刪除無用的雜物:

            $ git gc

             

            8. 其它

            忽略某些文件及目錄

            $ vi .gitignore

            可以使用通配符,目錄最后不要加斜杠。

             

            丟棄當(dāng)前所有未提交內(nèi)容

            $ git reset --hard HEAD

             

            有未提交內(nèi)容時(shí)快速切換到另一分支

            git stash save "work in progress for foo feature"
            切換到另一分支,并修改、提交
            切換回原來分支
            git stash apply
            Logo
            作者:Gezidan
            出處:http://www.rixu.net    
            本文版權(quán)歸作者和博客園共有,歡迎轉(zhuǎn)載,但未經(jīng)作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責(zé)任的權(quán)利。
            posted on 2011-08-11 11:50 日需博客 閱讀(431) 評(píng)論(0)  編輯 收藏 引用 所屬分類: 技術(shù)文章轉(zhuǎn)載未分類
            一本久久综合亚洲鲁鲁五月天| 亚洲精品无码久久千人斩| 久久久久国产精品三级网| 久久99精品国产麻豆婷婷| 久久中文字幕无码专区| 污污内射久久一区二区欧美日韩| 久久毛片一区二区| 色婷婷综合久久久久中文| 狠狠色丁香婷婷综合久久来| 国产99久久久久久免费看| 欧美成a人片免费看久久| 久久精品国产色蜜蜜麻豆| 久久久久久久久无码精品亚洲日韩 | 久久久久国产视频电影| 中文字幕无码av激情不卡久久| 性欧美大战久久久久久久久| 日本精品久久久久中文字幕| 午夜精品久久久久9999高清| 色婷婷综合久久久久中文| 99久久精品这里只有精品| 久久亚洲国产精品成人AV秋霞| 久久精品亚洲一区二区三区浴池| 国产精品99久久精品爆乳| 女人高潮久久久叫人喷水| AV无码久久久久不卡蜜桃| 久久影院亚洲一区| 国产91色综合久久免费| 久久有码中文字幕| 97久久精品午夜一区二区| 日本久久久久久久久久| 久久精品水蜜桃av综合天堂| 久久一区二区三区99| 2021少妇久久久久久久久久| 午夜精品久久久内射近拍高清| 国产精品美女久久久久久2018| 亚洲欧洲久久久精品| 人人狠狠综合久久亚洲婷婷| 狠狠色婷婷久久综合频道日韩 | 热RE99久久精品国产66热| 久久发布国产伦子伦精品| 久久国产精品无|