2015年1月29日 星期四

Git Branch / Tag / 檔案操作

Git Branch

Git的好處是可以再本地端開branch , 不會影響到遠端(Server端)的Repository



列出目前的branchgit branch
建立本地 local branchgit branch <new_branch_name>
切換branchgit checkout <new_branch_name>


git branch branchname  : 建立新的branch , 叫做branchname
git checkout branchname : 切換到 branchname
git branch : 顯示local的所有branch
git branch -r : 顯示remote的所有branch
git branch -d <branch_name> : 可以刪除 branch。但如果要刪除的 branch 還沒有合併,就會有錯誤訊息。如果真的要強制刪除可以用 -D
git branch -a : 顯示出所有「本地分支」與「本地追蹤分支」。「本地追蹤分支」就是紅字的部分(brian:本地追蹤分支應該就是遠端的branch )


git 檔案操作

git checout filename    :   會把檔案恢復到前一次commit , (當檔案在 modified status , unstage)
git reset filename : 檔案從stage恢復成 modified status.
git rm --cached filename : 檔案變成 untracked , 這個動作還是要commit
git rm filename  會真的移除檔案
git mv filename_from filename_to 




git tag


git tag : 列出現有標籤
git tag -l "Tname" : 搜尋名稱為"Tname"的tag

git tag -a "Nname"  : 增加一個tag 在目前的位置
git tag -a "Nname" commit-id增加一個tag 在指定的commit版本 , commit只要輸入前面幾個byte

git push origin tagA  : 把local的tagA push上去remote

git stash




Git的官方文件 : http://git-scm.com/book/zh-tw/v1/%E9%96%8B%E5%A7%8B ref : https://ihower.tw/blog/archives/2620

沒有留言:

張貼留言