1、$ sudo apt-get install -y git #安装
2、$ git --version #查看版本
3、$ sudo mkdir git_exercise
$ sudo git init #初始化仓库
4、$ git status #是否为最新代码,有什么更新等
5、$ git add hello.txt #添加到暂存区,用于commit
$git add -A #提交目录下的所有
6、$ sudo git config --global user.name "ndz"
$ sudo git config --global user.email "535704264@qq.com" #设置用户及邮箱
7、$ sudo git commit -m "Initial commit" #提交并添加描述信息
8、$ sudo git remote add origin https://gitee.com/voider_ni/hello #将本地仓库链接到远程项目,一个项目可以同时拥有好几个远程仓库,主要的称为 origin ,注意远程仓库仅仅创建即可,不要在页面提交任何东西
8.1 $ sudo git remote rm origin
9、$ git push origin master #从本地上传到远程服务器
10、$ git pull origin master #从远程服务器获取更新
11、$ sudo git branch new_branch #创建新的分支
12、$ git branch #查看分支状态
13、$ git checkout new_branch #切换分支
14、$ sudo git merge new_branch #将 new_branch 合并到master
15、$ git branch -d new_branch #删除new_branch分支
原文:https://www.cnblogs.com/jzsg/p/10597654.html