git第一次上传文件至远程仓库的流程
1 初始化git仓库
1 一定要再最上级模块的同级目录下创建。如user模块是最上级模块,所以在10 gitTes
这个目录内使用git init
命令初始化本地仓库。
2 在10 gitTes
目录内添加一个 .gitignore
文件
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
2 提交至本地仓库的操作流程
0 第一次初始化仓库必看
git 第一次初始化时一定要先使用git add
.和git commit -m
"提交信息"
这两个命令后才会出现master分支,并且可以创建其它分支。
1 添加至暂存区(注意add
和.
之间是由空格的)
git add .
2 提交到本地仓库
git commit -m "第一次提交"
3 分支操作
1 查看所有分支
git branch
2 打分支(本次新建名为base_branch
的分支)
git branch base_branch
3 提交到远程仓库
1 查看远程仓库(第一次什么都没有)
git remote -v
2 添加远程仓库链接
去gitee上把远程仓库的地址复制下来然后,添加远程仓库。
此处远程仓库名为origin
示例:git remote add origin https://gitee.com/sucrecc/java.git
git remote add 远程仓库名 远程仓库的地址
3 推送至远程仓库
origin
是远程仓库名 base_branch
是分支名
git push origin base_branch
4 操作失误解决
1 远程仓库添加错了怎么办
git remote set-url 远程仓库名 新的地址