git 经常使用操做

在gitee上新建立项目后,将本地的项目提交到git上去git

 

git init

touch README.md

git add .

git commit -m 'first commit'

git remote add origin https://gitee.com/abc/abc.git

git push -u origin master

 

将项目push到仓库的时候,由于仓库中的项目非空,因此会报错:fetch

To gitee.com:abc/abc.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@gitee.com:abc/abc.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

 因此先pull项目spa

git pull

git push -u origin master

 

报错:code

To gitee.com:abc/abc.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@gitee.com:abc/abc.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

 提示版本落后于线上的项目,线上的内容是没有用的,因此强制推送一次blog

git push -u -f origin master

 

成功后建立多个分支:ip

 查看本地分支和远程分支rem

git branch

git branch -r

 

建立分支it

git checkout -b v1.0 origin/mastergit push origin HEAD -u
相关文章
相关标签/搜索