一、新建码云项目

二、idea新建项目

1.项目根下新建新建README.MD 和.gitignore

.gitignore忽略提交文件


*.class

#package file

*.war
*.ear

#kdiff3 ignore
*.orig

#maven ignore
target/

#eclipse ignore
.settings/
.project
.classpathch

#idea
.idea/
/idea/
*.ipr
*.iml
*.iws

# temp file

*.log
*.cache
*.diff
*.patch
*.tmp

#system ignore
.DS_Store
Thumb.db

2.点idea 下方的Terminal

git init

3.git status 查看git状态,git add .添加新增修改的文件



4.再git status 查看添加的文件



5.git commit -am "first commit init project" 提交修改的文件到本地库



6.把项目push到远程仓库

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



7.查看分支git branch



第一次推送报错

推送远程git push -u origin master

 ! [rejected]        master -> master (fetch first)

error: failed to push some refs to 'https://gitee.com/liziming/mmail.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.



错误解决:先执行git pull



再执行:提示当前分支落后远程版本

git push -u origin master

To https://gitee.com/liziming/mmail.git

 ! [rejected]        master -> master (non-fast-forward)

error: failed to push some refs to 'https://gitee.com/liziming/mmail.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.



8.强制推送 git push -u -f  origin master



9.git branch 查看本地分支 git branch -r 查看远程分支



10.新建远程分支,从主分支中新建v1.0分支

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'



提示本已经切换到v1.0分支



11.把分支推送到远程git push origin HEAD -u


三:修改提交代码

1.git status 查看本地 修改状态

2.git add . 添加修改的文件 git status

3.git commit -am 'modify commit' -a 提交 m 提交说明

4.提交远程 git push 

查看分支 git branch