發表文章

目前顯示的是 9月, 2014的文章

Git Submodule command line sample

Submodule Data Source:  http://blog.jacius.info/git-submodule-cheat-sheet/ Recipes Note: the  [main]$  bits on each line represents your bash prompt. You should only type the stuff after the $. Set up the submodule for the first time: [ ~ ] $ cd ~/main/ [ main ] $ git submodule add git://github.com/my/submodule.git ./subm [ main ] $ git submodule update --init [ main ] $ git commit ./submodule -m "Added submodule as ./subm" Fetch submodules after cloning a repository: [ ~ ] $ git clone git://github.com/my/main.git ~/main [ ~ ] $ cd ~/main/ [ main ] $ git submodule update --init Pull upstream main repo changes and update submodule contents: [ main ] $ git pull origin/master [ main ] $ git submodule update Pull upstream changes to the submodule: [ main ] $ cd./subm [ subm ] $ git pull origin/master # or fetch then merge [ subm ] $ cd .. [ main ] $ git commit ./subm -m "Updated submodule reference" ...

Git command line samples

Git command recipes init $ git init $ git init --bare status $ git status add $ git add <file> $ git add <file> --patch $ git add -u #只包含刪除的檔案,不包含新增檔案 $ git add . #只包含修改和新增,不包含刪除 $ git addall #通通加到 staging area addall = !sh -c 'git add . && git add -u' commit $ git commit checkout $ git checkout <file> $ git checkout <SHA1> $ git checkout <branch_name> $ git checkout -b <new_branch_name> $ git checkout --orphan <new_branch_name> diff $ git diff <SHA1> $ git diff <SHA1> <SHA1> $ git diff --stat <SHA1> $ git diff --cached [file] $ git diff --staged [file] reset $ git reset <file> $ git reset HEAD --hard #放棄合併 $ git reset <SHA1> $ git reset HEAD^ #留著修改在 working tree $ git reset HEAD^ --soft #留著修改在 staging area $ git reset HEAD^ --hard #完全清除所有修改 revert $ git revert <SHA1> $ git revert <branch> branch $ git branch <branch_name> $ git bran...