git使用情景3:最常见的解决冲突
来源:互联网 发布:文爱社交软件 编辑:程序博客网 时间:2024/05/16 05:42
本地代码修改完毕,该提交了,开始准备提交
【看一眼当前状态,命令:git status】
B000000095605B:test baidu$ git status
On branch masterYour branch is up-to-date with 'origin/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: gradle.properties
no changes added to commit (use "git add" and/or "git commit -a")
【看到了自己只修改了一个文件,好的,执行add】
B000000095605B:test baidu$ git add .
【执行commit】
B000000095605B:test baidu$ git commit -m "我修复了一个bug"[master 8e1d5bb] 我修复了一个bug
1 file changed, 1 insertion(+)
【执行push到远程】
B000000095605B:test baidu$ git pushTo https://github.com/yiwowang/test.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/yiwowang/test.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.
【我靠,什么情况?没有push成功,咋被服务器拒绝了呢。原来是这个文件有冲突,也就是远程仓库的此文件被另一个人改了,好吧,我把远程代码拉下来吧】
B000000095605B:test baidu$ git pull --rebase
remote: Counting objects: 3, done.remote: Total 3 (delta 1), reused 1 (delta 1), pack-reused 2
Unpacking objects: 100% (3/3), done.
From https://github.com/yiwowang/test
d239d59..f4b4a74 master -> origin/master
First, rewinding head to replay your work on top of it...
Applying: 我修复了一个bug
Using index info to reconstruct a base tree...
M gradle.properties
Falling back to patching base and 3-way merge...
Auto-merging gradle.properties
CONFLICT (content): Merge conflict in gradle.properties
error: Failed to merge in the changes.
Patch failed at 0001 我修复了一个bug
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
【可以看到这句话:CONFLICT (content): Merge conflict in gradle.properties,说明这个文件冲突,我就打开这个文件解决冲突】
【冲突解决完毕,然后看一下状态】
B000000095605B:test baidu$ git statusrebase in progress; onto f4b4a74
You are currently rebasing branch 'master' on 'f4b4a74'.
(fix conflicts and then run "git rebase --continue")
(use "git rebase --skip" to skip this patch)
(use "git rebase --abort" to check out the original branch)
Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both modified: gradle.properties
no changes added to commit (use "git add" and/or "git commit -a")
【执行add】
B000000095605B:test baidu$ git add .
【看一下所处于的分支,发现是一个临时分支,还没有rebase完成】
B000000095605B:test baidu$ git branch
* (no branch, rebasing master)
dev
master
【继续rebase】
B000000095605B:test baidu$ git rebase --continueApplying: 我尝试提交
【看一下状态,说明可以push了】
B000000095605B:test baidu$ git statusOn branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
【执行push】
B000000095605B:test baidu$ git pushCounting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 314 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com/yiwowang/test.git
f4b4a74..6e7cf9a master -> master
【在看一下状态,“没有需要提交的了,工作空间是干净的”】
B000000095605B:test baidu$ git statusOn branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
- git使用情景3:最常见的解决冲突
- Git常见冲突解决
- Git常用命令的使用情景
- Git常用命令的使用情景
- Git常用命令的使用情景
- git 冲突的解决
- git的冲突解决
- git冲突的解决
- GIT 冲突的解决
- git 冲突的解决
- git的冲突解决
- git的最常见的使用
- Git版本控制的使用以及Git冲突解决
- eclipse使用git解决冲突
- git 使用P4Merge解决冲突
- Git 使用rebase解决冲突
- Git情景使用
- Git下的冲突解决
- express安装及第一个应用
- 安卓sdk有几层基础架构组成?各层的主要功能,组成个是什么?
- Spring详解及使用
- android学习心得
- 关于java多线程的记录
- git使用情景3:最常见的解决冲突
- fmdb +单例
- 卡特兰数组
- git 客户端使用
- 贝塞尔曲线扫盲
- 无法启动此程序,因为计算机中丢失opencv_core2410d.dll vs2010
- 旋转字符串
- python获取网页响应时间
- C++ const用法 尽可能使用const