Git是個了不起但卻複雜的源代碼管理系統。它能支持複雜的任務,卻因此經常被認為太過複雜而不適用於簡單的日常工作。讓我們誠實一記吧:Git是複雜的,我們不要裝作它不是。但我仍然會試圖教會你用(我的)基本的Git和遠程代碼庫幹活的工作步驟,在15分鐘內。
安裝Git
git clone https://github.com/git/git |
創建一個遠程代碼庫
git config --global user.name "your_username" git config --global user.email your_email@domain.com |
git config --global push.default simple |
cd ~/workspace/my_site/ |
cd c:\workspace\my_site |
git init |
git add . |
git add my_file, my_other_file |
git commit -m "initial commit" |
git status |
git checkout -b new_feature |
git branch new_featuregit checkout new_feature |
git branch |
git add .git commit -m "adds my new feature" |
git checkout master |
git merge new_feature |
git add .git commit -m "feature to be discarded" |
git checkout master |
git branch -d new_feature |
git branch -D new_feature |
git log |
commit ca82a6dff817ec66f44342007202690a93763949Author: your_username your_email@domain.comDate: Mon Nov 4 12:52:11 2013 -0700 changes the frontpage layout commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7Author: your_username your_email@domain.comDate: Mon Nov 4 11:40:33 2013 -0700 adds my new feature commit a11bef06a3f659402fe7563abf99ad00de2209e6Author: your_username your_email@domain.comDate: Mon Nov 4 10:37:28 2013 -0700 initial commit |
git checkout 085bb3bcb |
git checkout -b my_previous_version 085bb3bcb |
git remote add origin https://your_username@bitbucket.org/your_username/name_of_remote_repository.git |
git push origin master |
git clone https://your_username@bitbucket/your_username/name_of_remote_repository.git |
git pull origin master |
git config --global alias.c 'commit -m' |
git config --global alias.c 'commit -m' git config --global alias.co 'checkout' git config --global alias.cob 'checkout -b' git config --global alias.br 'branch' git config --global alias.m 'merge' git config --global alias.a 'add .' git config --global alias.s 'status' git config --global alias.dbr 'branch -d' |
[火星人 ] 15分鐘學會使用Git和遠程代碼庫已經有1217次圍觀