git笔记


Basic Commands

source: http://huangziwei.com/tech/blogging-with-git-github-and-jekyll/
git remote -v, git remote show origin - 检测文件夹是否已绑定远程库(remote repository)
git remote add origin <remote git repository> - 绑定fork的远程库
git checkout <file to ignore>
git checkout -b|--orphan <branchname> - normal|disconnected branch

branch

source: https://www.atlassian.com/git/tutorials/using-branches/git-branch

Submodules 使用副项目并随时得到更新

source: https://medium.com/@porteneuve/mastering-git-submodules-34c65e940407#.kcyfdl2xi, http://johnleach.co.uk/words/323/git-submodules-in-n-easy-steps, https://johnleach.co.uk/words/323,
https://blog.jacius.info/git-submodule-cheat-sheet/, http://blog.chh.tw/posts/git-submodule/, http://springok-blog.logdown.com/posts/2015/11/06/submodule-on-github-subproject-troubleshooting

git submodule add <others .git repository> <myfolder> 
-- set up .gitmodules for myfolder      
git commit .gitmodules <myfolder> -m "a message"  
git push

# after cloning tree, fetch all submodules  
git submodule init Submodule 'myfolder'  
git submodule update    

# updating submodule  
cd myfolder && git pull [from others] && git add myfolder && commit    

# making changes to your submodule  
cd myfolder && git checkout master [do changes in that branch]  
git commit -a -m "fix a bug" && push  
cd .. && git add myfolder && commit -m "updated myfolder"