
-
Git安装
1
2
3$ git
The program 'git' is currently not installed. You can install it by typing:
sudo apt-get install git -
Git设置
1
2$ git config --global user.name "Your Name"
$ git config --global user.email "[email protected]" -
初始化
1
2
3
4
5$ git init
$ git add <file>
$ git commit -m <message> -
查看Git状态
1
2
3$ git status
$ git diff -
查看历史版本
1
2
3$ git log
$ git reflog -
撤销修改
1
2
3$ git checkout -- file
$ git reset HEAD <file> -
删除文件
1
$ git rm
-
添加远程仓库
1
2
3
4
5$ git remote add origin [email protected]:path/repo-name.git
$ git push -u origin master
$ git push origin master -
从远程仓库克隆
1
$ git clone
-
分支管理
1
2
3
4
5
6
7
8
9
10
11查看分支:git branch
创建分支:git branch <name>
切换分支:git checkout <name>
创建+切换分支:git checkout -b <name>
合并某分支到当前分支:git merge <name>
删除分支:git branch -d <name> -
从远程仓库拉取分支
1
$ git pull




近期评论