Git02常用命令

1、设置个人信息

git config --global user.name "xxx"
git config --global user.email "xxx@xxx.xxx"

2、提交

#初始化本地git
cd hello-git
git init

#新建README文件
touch README
git add README

#提交文件到本地Git
git commit -m 'first commit'

#提交文件到远程Git
git remote add origin git@github.com:username/hello-git.git
git push -u origin master

3、取回

git clone git@github.com:username/hello-git.git

取回(包含子模块)

git clone --recursive -j6 git@github.com:username/hello-git.git

取回(包含子模块)

git clone git@github.com:username/hello-git.git
cd hello-git
git submodule update --init --recursive

4、Fork

#产生Fork后取回
git clone git@github.com:username/hello-git.git
cd hello-git

#追加上级代码信息
git remote add upstream git://github.com/SomeOne/hello-git.git
git fetch upstream
#合并上级代码
git fetch upstream
git merge upstream/master

5、创建分支

#创建分支
git checkout -b mybranch

6、合并分支

#合并分支
git checkout master
git merge mybranch
git branch -d mybranch

7、改变远程库地址

git remote set-url origin 新地址

Leave a Reply

Your email address will not be published. Required fields are marked *

*