2016年4月5日 星期二

Git 命令整理

git add 新增檔案
git add . 新增目錄下所有檔案
git commit 提交檔案
git commit -m 'message' 直接提交,不進入編輯器
git commit 提交檔案,進入編輯器
git commit --amend 編輯已提交的註釋
git reset 回復檔案
git reset 放棄add,保留修改
git reset --hard 放棄所有修改,回到上個提交的狀態
git reset --hard HEAD 回到最新提交的版本
git reset --hard HEAD^ 回到前一個提交的版本
git branch 分支
git branch 列出所有branch
git branch -a 列出所有本地和遠端的branch
git branch <new-branch> 依目前branch,建立新的branch
git checkout 切換
git checkout <branch> 切換branch
git checkout master 切換到master
git checkout <new-branch> master 從master建立新的branch,並切換到新的branch
git checkout -b <new-branch> 依目前branch建立新的branch,並切換到新的branch
git checkout <file> 重新checkout此檔案
git log
git log 列出所有log
git pull
git pull 將遠端的檔案更新到本地
git push
git push 將本地檔案更新到遠端
參考來源
https://www.atlassian.com/git/tutorials/setting-up-a-repository
https://git-scm.com/doc
https://backlogtool.com/git-guide/tw/

沒有留言:

張貼留言