初始化操作
$
git config -global user.name
<name
>
$
git config -global user.email
<email
>
$
git config -global core.editor
<editor
>
$
git config -global merge.tool
<tool
>
$
git config -list
创建新版本库
$
git clone
<url
>
$
git init
修改和提交
$
git add
.
$
git add
<file
>
$
git mv <old
> <new
>
$
git rm <file
>
$
git rm -cached
<file
>
$
git commit -m
<file
>
$
git commit -m “commit message”
$
git commit -amend
$
git commit -C HEAD -a -amend
撤消操作
$
git reset -hard HEAD
$
git checkout HEAD
<file1
> <file2
>
$
git checkout HEAD.
$
git revert
<commit
>
// 删除恢复例:
$
git rm eee
$
git reset --hard
$
git checkout HEAD eee
$
git checkout HEAD
.
$
git revert
查看提交历史
$
git log
$
git log -p
<file
>
$
git blame
<file
>
$ gitk
$ gitk
<branch
>
$ gitk --all
$
git branch -v
$
git status
$
git diff
分支与标签
$
git branch
$
git checkout
<branch/tagname
>
$
git branch
<new-branch
>
$
git branch -d
<branch
>
$
git tag
$
git tag
<tagname
>
$
git tag -d
<tagname
>
合并与衍合
$
git merge
<branch
>
$
git rebase
<branch
>
$
git checkout dev
$
touch 分支two测试
$
git checkout test-branch
$
git merge two
远程操作
$
git remote -v
$
git remote show
<remote
>
$
git remote add
<remote
> <url
>
$
git fetch
<remote
>
$
git pull
<remote
> <branch
>
$
git push
<remote
> <branch
>
$
git push
<remote
> : <branch
>/
<tagname
>
$
git push -tags
Git命令图解
Xmind转载来源:Linux公社