git提交步骤
来源:互联网 发布:电商童装行业数据分析 编辑:程序博客网 时间:2024/05/19 17:04
好久没用GIT,再次捡起来,遇到了些错误,比如没写comment,导致没提交成功,没有先从远程pull,导致没push成功。
于是将这个过程记录如下:
1:首先,跳转到项目根目录
2:查看当前状态
3:把我们要提交的文件的信息添加到索引库中
4: 提交文件到本地库
5:合并到远程代码库(首先要将远程库,pull到本地,否则不能push)
5.1:没有将远程库pull到本地,报错:
6:pull远程到本地
7:设置 git ignore 过滤文件,.class 后缀文件不提交到远程
8:再次push,成功
具体如下:
1:首先,跳转到项目根目录
Administrator@JS-PC /e/abc
$ cd CanYin-www
Administrator@JS-PC /e/abc/CanYin-www (master)
$ ls
LICENSE README.md pom.xml src target
2:查看当前状态
$ git status;
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: src/main/java/cn/canyin/dao/MenuDao.java
...
Untracked files:
(use "git add <file>..." to include in what will be committed)
src/main/java/cn/canyin/dao/Dao.java
...
no changes added to commit (use "git add" and/or "git commit -a")
3: 把我们要提交的文件的信息添加到索引库中
Administrator@JS-PC /e/abc/CanYin-www (master)
$ git add .
4: 提交文件
Administrator@JS-PC /e/abc/CanYin-www (master)
$ git commit -a #注意这一步要写comment
[master dfce490] add menu model, changed by jonsanguo at 20140408
27 files changed, 546 insertions(+), 11 deletions(-)
create mode 100644 src/main/java/cn/canyin/dao/Dao.java
...
5:合并到远程代码库(首先要将远程库,pull到本地,否则不能push)
Administrator@JS-PC /e/abc/CanYin-www (master)
$ git push https://github.com/guojiangshan/canyin master
Username for 'https://github.com': guojiangshan
Password for 'https://guojiangshan@github.com':
Counting objects: 81, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (45/45), done.
Writing objects: 100% (49/49), 8.40 KiB | 0 bytes/s, done.
Total 49 (delta 16), reused 0 (delta 0)
To https://github.com/guojiangshan/canyin
66640ab..dfce490 master -> master
5.1:没有将远程库pull到本地,报错:
$ git push https://github.com/guojiangshan/canyin master
Username for 'https://github.com': guojiangshan
Password for 'https://guojiangshan@github.com':
To https://github.com/guojiangshan/canyin
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/guojiangshan/canyin'
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.
6:pull远程到本地
$ git pull https://github.com/guojiangshan/canyin master
warning: no common commits
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 5 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (5/5), done.
From https://github.com/guojiangshan/canyin
* branch master -> FETCH_HEAD
Merge made by the 'recursive' strategy.
.gitignore | 11 ++
LICENSE | 339 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
README.md | 4 +
3 files changed, 354 insertions(+)
create mode 100644 .gitignore
create mode 100644 LICENSE
create mode 100644 README.md
7:设置 git ignore 过滤文件,.class 后缀文件不提交到远程
$ echo *.class>.gitignore
查看设置是否成功:
$ cat .gitignore
*.class
8:再次push,成功
$ git push https://github.com/guojiangshan/canyin master
Username for 'https://github.com': guojiangshan
Password for 'https://guojiangshan@github.com':
Counting objects: 116, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (102/102), done.
Writing objects: 100% (115/115), 58.02 KiB | 0 bytes/s, done.
Total 115 (delta 6), reused 0 (delta 0)
To https://github.com/guojiangshan/canyin
f7ddeea..5fd03b6 master -> master
- git提交代码步骤
- git提交步骤
- git 远程提交步骤
- git提交步骤
- git提交代码步骤
- Git提交步骤
- git代码提交步骤
- git代码提交步骤
- git 提交步骤 个人备份
- git 更新提交项目步骤
- Git快速提交Github步骤
- git 提交代码的基本步骤
- Git提交工程的使用步骤
- git 合并分支和提交的步骤
- GIT提交到远程仓库的步骤
- git提交至远程仓库步骤
- myeclipse配置git提交项目步骤
- git stash提交PR的正确步骤&git squash技术
- JDBC 连接MySQL的使用。
- PAT乙级——1004 福尔摩斯的约会 (C/C++)
- DOTween -Init
- 子父类中的构造函数
- Hackerrank :Candies
- git提交步骤
- PAT乙级——1005 德才论 (C/C++)
- 蓝桥杯 基础练习 杨辉三角形
- UVA-264-CountonCantor
- 关于json数据
- Maven学习五之Nexus中各repository介绍
- Cordova 用iOS做webApp壳
- UI第01天:iOS编程入门总结
- ubuntu安装as86 ld86