git 的简单操作

1.从线上克隆代码

git clone [https/ssh]

2.查看git状态

git status  

3.将新代码添加到本地仓库

git add .

4.给新代码添加说明

git commit -m 'message'

5.将本地仓库中的代码添加到线上

git push

6.从线上仓库下拉代码

git pull

7.切换分支

git checkout [branch-name]

注:如果从线上新建了一个分支,要先pull一下再切换。

8.合并分支,以master分支为例

git checkout master
git merge origin/[branch-name]
git push

9.把本地的目录变成git本地仓库

git init

10.将本地仓库与远程仓库关联起来

git remote add origin [远程仓库地址]

11.第一次向远程仓库提交失败,可以尝试以下命令强制提交

git push -u origin master -f 

你可能感兴趣的:(git,github)