Git常用指令集合 (持續更新)
這裡列出平常使用git時常用的指令,內容隨時更新。為何要筆記呢?因為有些久了沒用會忘記 :p
建立local repository
git init
將local repository和遠端的repository關聯 ($URL請用真實的URL替換)
git remote add origin $URL
新增檔案 ($fileName請用真實檔名替換)
git add $fileName
git add *
新增已存在repository中有更新的檔案
git add -u
commit檔案
git commit -m "type your message here"
將local repository的變更推送到遠端的repository
git push -u origin master
git push
顯示每一版commit有變動的檔案名稱
git log --stat
git log --name-only
git log --name-status
顯示目前git由何處clone得來
git remote show origin
設定使用者資訊
$ git config --global user.name "Foo Bar"
$ git config --global user.email foobar@example.com
顯示repository的所有branch
git branch -a
切換branch
git checkout $branch_name
刪除branch
git branch -D $branch_name
本地branch推送至remote
git push origin $branch_name
留言
張貼留言