git - JasonWayne/personal-wiki GitHub Wiki

教程

官方教程Try Git,非常非常好,强烈推荐。用一段时间Git后再过一遍教程,仍然受益匪浅,记得看右下角的advice。推荐从CodeSchool中进入。 http://www.bootcss.com/p/git-guide/

可以参考的资料

  1. Git Documentation
  2. Pro Git book
  3. Github Help

自己在服务器上搭建Git

参考http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/00137583770360579bc4b458f044ce7afed3df579123eca000http://www.it165.net/os/html/201402/7303.html 主要流程参考前一篇,后一篇主要参考了如何生成id_rsa.pub文件。如果不添加该文件,每次操作都需要输入密码,非常麻烦,这里与配置Hadoop非常相似。

回滚

git reset HEAD 如果遇到Unstaged changes after reset: 可以 git stash git stash drop

revert last commit

# https://stackoverflow.com/questions/927358/how-to-undo-the-most-recent-commits-in-git
# if local
git log
    commit 101: bad commit    # latest commit, this would be called 'HEAD'
    commit 100: good commit   # second to last commit, this is the one we want

git reset --soft HEAD^     # use --soft if you want to keep your changes
git reset --hard HEAD^     # use --hard if you don't care about keeping the cha

删除提交历史中的几条记录

参考

git rebase -i 6d38262456eedf0c1919da6df4303280fcb5463c^

cancel a merge with unexpected conflicts

git merge --abort

revert a file

git checkout -- path_of_file

rename a branch

reference

git branch -m <oldname> <newname>
# if rename current branch
git branch -m <newname>

etc

git ignore & exclude

⚠️ **GitHub.com Fallback** ⚠️