美文网首页
2019-11-19 Idea当中上传项目到码云

2019-11-19 Idea当中上传项目到码云

作者: 惜小八 | 来源:发表于2019-11-19 21:21 被阅读0次

1.git代码提交到git

➜  mmall touch README.md
➜  mmall touch .gitignore

#初始化git仓库,使当前目录成为工作空间
➜  mmall git init
#添加所有的工作空间当中的文件到暂存区
➜  mmall git add .
#将赞存区文件添加到本地仓库
➜  mmall git:(master) git commit -am 'first commit init project'
[master (root-commit) 1c03748] first commit init project
 5 files changed, 113 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 README.md
 create mode 100644 pom.xml
 create mode 100644 src/main/webapp/WEB-INF/web.xml
 create mode 100644 src/main/webapp/index.jsp

#添加远程地址:此处添加到远程的地址,要我们自己去码云上复制地址git@gitee.com:superzqbo/mmall_learning.git
➜  mmall git:(master) git remote add origin git@gitee.com:superzqbo/mmall_learning.git

➜  mmall git:(master) git branch
#将本地文件上传到远程上
➜  mmall git:(master) git push -u origin master
To gitee.com:superzqbo/mmall_learning.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@gitee.com:superzqbo/mmall_learning.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.        #提示在push之前要先pull
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
➜  mmall git:(master) git pull
warning: no common commits
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 5 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (5/5), done.
From gitee.com:superzqbo/mmall_learning
 * [new branch]      master     -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

➜  mmall git:(master) git push -u origin master
To gitee.com:superzqbo/mmall_learning.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@gitee.com:superzqbo/mmall_learning.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.
➜  mmall git:(master) 
➜  mmall git:(master) git push -u -f origin master  # -f:强制上传
Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 8 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (11/11), 1.58 KiB | 810.00 KiB/s, done.
Total 11 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-3.8]
To gitee.com:superzqbo/mmall_learning.git
 + 20b0081...1c03748 master -> master (forced update)
Branch 'master' set up to track remote branch 'master' from 'origin'.
➜  mmall git:(master) 


#打开码云,刷新即可看到我们上传的项目

2.git分支创建

# 在开发当中我们一般采用的是分枝开发,主干发布的方式
# 在主干的基础上创建分支用以开发
git checkout -b v1.0 origin/master #在主干origin/master下创建分支v1.0
# 可以采用git branch 查看本地的分支

#将分支推送到远程的git上
git push origin HEAD -u
#分支v1.0是在master的基础上复制的
#此时在码云上即可看到新创建的分支
========================================================

➜  mmall git:(master) git checkout -b v1.0 origin/master
Branch 'v1.0' set up to track remote branch 'master' from 'origin'.
Switched to a new branch 'v1.0'
➜  mmall git:(v1.0) git branch -r
➜  mmall git:(v1.0) git push origin HEAD -u
Total 0 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-3.8]
remote: Create a pull request for 'v1.0' on Gitee by visiting:
remote:     https://gitee.com/superzqbo/mmall_learning/pull/new/superzqbo:v1.0...superzqbo:master
To gitee.com:superzqbo/mmall_learning.git
 * [new branch]      HEAD -> v1.0
Branch 'v1.0' set up to track remote branch 'v1.0' from 'origin'.
➜  mmall git:(v1.0) git branch -r
➜  mmall git:(v1.0) 

相关文章

网友评论

      本文标题:2019-11-19 Idea当中上传项目到码云

      本文链接:https://www.haomeiwen.com/subject/kovgictx.html