1.创建一个读我文件:touch README.md
2.创建.gitignore:touch .gitignore
3.git初始化,会成为一个空的git文件:git init
Initialized empty Git repository in C:/.git/
4.看项目中改变的文件:git status
5.将文件填进来:git add .
6.在看项目中的文件以改变:git status
7.提交到本地仓库里,-am后表示加注释:git commit -am '注释内容'
8.连接远程仓库:git remote add origin +git仓库的ssh地址
9.查看分支:git branch
10.把本地分支推送到远程上:git push -u origin master
报的错误:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'gitee.com:gitee12399/che.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.
11.将分支上的文件拉取上来:git pull
12.再一次把本地分支推送到远程上:git push -u origin master
报的错误:
To gitee.com:gitee12399/che.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'gitee.com:gitee12399/che.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.
13.强制推送,将master覆盖:git push -u -f origin master
14.看当前的分支:git branch
15.看远程的分支:git branch -r
origin/master
分支开发,主干发布
16.创建分支,v1.0是分支的名字:git cheakout -b v1.0 origin/master
17.查看分支:git branch
18.推送到远程:git push origin HEAD -u
报错:在第10部时与上面报错不同
报的错
error: src refspec develop does not match any
error: failed to push some refs to 'gitee.com:gitee12399/che.git'
解决方式:
输入如下代码:
1.git add .
2.git commit -m "write your meaaage"
原因:提交时未加备注信息
解决方法来源:https://segmentfault.com/q/1010000004615080
.gitignore文件:想要忽略的文件
*.class
#package file
*.war
*.ear
#kdiff3 ignore
*.orig
#maven ignore
target/
#eclipse ignore
.settings/
.project
.classpatch
#idea
.idea/
/idea/
*.ipr
*.iml
*.iws
#temp file
*.log
*.cache
*.diff
*.patch
*.tmp
#system ignore
.DS_Store
Thumbs.db