安装
在Linux系统中安装Git(以Ubuntu为例)
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git
在Mac OS中安装Git
brew install git
在Windows系统中安装Git
下载Git并安装 https://git-scm.com/download/win
配置
git config --global user.name "your git username"
git config --global user.email "your email address for git"
添加文件到repository
首先切换路径到本地repository,写明要commit到本地repository的文件:
git add .
commit刚才添加到本地repository的文件并添加更新说明信息:
git commit -m "Add new files"
push所做的改变到GitHub:
git push origin your-branch
撤销操作 - reverting a commit
You can revert a specific commit to remove its changes from your branch. When you revert to a previous commit, the revert is also a commit. The original commit also remains in the repository's history.
这里值得注意的一点是,revert到之前的某一次commit,这本身其实仍然是一个commit,所以之前的那次commit仍然会在repository的历史中显示。
git revert <commit-hash> -m
如果是想撤销前一次的merge commit:
git revert <commit-hash> 1 -m