linux 分布式 程序管理,linux--------------git分布式系统项目管理(1)
這幾天重慶還真是熱啊,不過在實驗室還算不錯,也是個不錯的環境。之前在做內核相關的東西的時候就經常在github下載源碼,覺得挺好用的,當時我也是想等有空的時候要好好學一下怎么使用的。看了兩天的pdf了,感覺還是有很多收獲和理解,在此與大家分享,同時也勉勵自己繼續學習,努力,加油。在這邊博客中,過多的命令的含義我并不詳細敘述,因為我的敘述比這本書《progit.zh》差遠了,這本書很詳細,很注重理解,所以我覺得是本好書,如果想要學習git,那就從這本書開始吧,沒有比這個更好的了。
(1) 安裝git,若直接用sudo apt-get install安裝的話,那版本估計是比較老的版本了,所以最好下載新的版本,官網下載不到,所以我找了很久,終于在unixChina上面找到了源碼,然后通過make prefix=/usr all,make prefix=/usr install安裝好了.
(2) 用戶信息配置:
git config --global usr.name "xiaogaogao"
git config --global usr.emailgaozw1988@126.com
git conifg --global core.editor vi
通過git config --list 可以查看配置信息
(3)?對現有項目開始用git管理:
$: git init;
$: git add .
$: git commit -m "initial project version"
其中git status 可以查看當前項目的狀態,另外還有些查看差異什么的,我用的較少,畢竟我沒有真正的開發什么大項目,所以掌握肯定不夠全面。
(4)? 查看當前的遠程庫:git remote -v
添加遠程倉庫:?????? git remote 【shortname】 【url】,就相當于可以用shortname代替那個網址了。
抓取數據:????????????? git fetch(pull) 【remote-name】(git fetch origin)
(5)? 這部分的內容就是分支的理解了,其實還是不錯的,這些都是要理解的,理解了才能用好這個工具。用到時時候應該使很多的,尤其是大項目,涉及到分支和合并的東西。主要的命令為:
$:git checkout master
$:git checkout -b iss53 ;新建iss53分支,并切換到這個分支上去;
$:git merge hotfix ;合并分支hotfix和master分支;
$:git branch -d hotfix;刪除分支hotfix,在講這個內容合并到主分支之后一般會這樣;
$:git branch (-v); 列出當前所有的分支
$:git branch --merged(--no-merged)查看已經合并(未合并的)的分支;
(6) 遠程分支:
這部分主要理解為從網絡上得到的為origin/master分支,在你開發的過程中,這個位置是保持不變的,變化的是你的master;
別人也在自己的電腦上得到origin/master分支,在他的開發過程中,這個位置也是保持不變的,變化的是他的master;
假如別人已經開發完畢,他合并到網絡上的分支,這是網絡上就已經變化了,你再從網絡上得到的時候,就會更新你電腦上的origin/master的位置。但是你的mater的上層節點還是之前的那個,沒有發生變化。
假如還有一個she也在做開發,你可以通過
$:git remote add? temeone將temeone的分支假如到你的項目之中;
$:git fetch? teamone 或者she的服務器上面的數據;
假如你想將自己的serverfix分支推送到網絡上的awesomebranch分支去(這個分支可以沒有,會自動創建)
$:git push origin serverfix:awesomebranch;
這是你的小伙伴在此從服務器上面獲取數據的時候,就會獲得你上傳的awesomebranch分支;
$:git fetch origin; 得到輸出:*【new branch】 serverfix -> origin/serverfix的字樣;
但是在fetch操作抓來新的遠程分支之后,你的小伙伴無法再本地編輯該遠程倉庫,他不會有一個新的serverfix分支,有的只是一個他無法移動的origin/serverfix指針;如果要把該內容合并到當前分支,可以運行:
$git merge origin/serverfix
若是要要一份自己的serverfix來開發,可以在遠程分支的基礎上分化出來一個新的分支:
$git checkout -b serverfix origin/serverfix; 這樣就可以在在本地切換到serverfix繼續做開發了;
衍合部分就不說了,理解多一些;如如圖所示吧:
?? ------>???
------->
$ git checkout experiment
$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: added staged command
----->
----->
-->
--------->
$:git rebase --onto master server client;這基本上等于在說“檢出 client 分支,找出client 分支和server 分支的共同祖先之后的變化,然后把它們在master 上重演一遍”
$ git checkout master
$git merge client $ git rebase master server
$ git checkout master
$ git merge server
$ git branch -d client
$ git branch -d server
------------------------------------------------------------------------------------------------------------上面的好亂。。。。。。。。。。。。。。。。。。。。
HTTPS cloning errors
There are a few common errors with using HTTPS with git.? These errors usually indicate you have an old version of git, or you don't have access to the repository.
The remote repository must exist on GitHub, and the URL is case-sensitive.
git remote -v
# View existing remotes
#origin https://github.com/github/reactivecocoa.git (fetch)
#origin https://github.com/github/reactivecocoa.git (push)
git remote set-url origin https://github.com/github/ReactiveCocoa.git
# Change the 'origin' remote's URL
git remote -v
# Verify new remote URL
#origin https://github.com/github/ReactiveCocoa.git (fetch)
#origin https://github.com/github/ReactiveCocoa.git (push)
Create a new repository on the command line
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/xiaogaogao/asdfas.git
git push -u origin master
Push an existing repository from the command line
git remote add origin https://github.com/xiaogaogao/asdfas.git
git push -u origin master
總結
以上是生活随笔為你收集整理的linux 分布式 程序管理,linux--------------git分布式系统项目管理(1)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux 权限模式,Linux权限模式
- 下一篇: linux 卸载aria2,Linux