2018/12/07

常用 Git Command

### Initialization ``` git clone git@bitbucket.org:jessewth/xxxxx.deployment.git git flow init -f -d git remote add upstream git@bitbucket.org:xxxxxi/nineyi.deployment.git ``` ### Remove remote branch ``` git push origin --delete feature/develop_release feature/master_for_release ``` ### Clean branch cache ``` git remote prune origin git fetch --prune ``` reference: [Git: Remove information on branches that were deleted on origin](https://makandracards.com/makandra/6739-git-remove-information-on-branches-that-were-deleted-on-origin) ### Git tag https://git-scm.com/book/en/v2/Git-Basics-Tagging ### 還原到未修改前的狀態 ``` git reset --hard ``` ### 還原到未修改前的狀態及刪除未 commit 的新檔 ``` git clean -fd ``` ##3 用 command line 看 git log ``` git log --oneline --decorate --all --graph ``` 為了方便使用, 把上述 command 加入 alias, 命名為 git tree, 下次要用的時候, 直接打 git tree 即可 ``` git config --global alias.tree "log --oneline --decorate --all --graph" ``` ### 回復單一個檔案的變更 ``` git checkout HEAD -- ../../ConnectionStrings.config ``` ### Git log search keyword ``` git log -g --grep="vsts28270" ```

軟體工程的重要的指標