git常用命令

1.本地初始化git目录

1
git init

2.新建文件并且写入内容

1
2
touch a.txt
echo "new data" >> a.txt

3.添加到暂存区

1
2
git add .
git commit -m "提交更新"

4.添加远程仓库

1
git remote add origin https://github.com/xxx/test.git

5.本地仓库也远程仓库关联

1
git branch --set-upstream-to=origin/master master

6.拉取远程仓库内容到本地

1
git pull origin master --allow-unrelated-histories

7.将最新的内容推送到远程仓库

1
git push