git使用技巧

一、解决冲突

场景:
(1) dev、master在一条线上(network)。
(2) dev:修改a.java的第xx行,提交并push
(3) master:修改a.java的第xx行,提交并push
(4) master合并dev会出现冲突

1. 界面

百度网盘/录课/自录视频/git冲突1

2. 命令行

git status

1
2
3
4
5
6
7
8
9
On branch develop
Your branch is up-to-date with 'origin/develop'.
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: hbase-monitor-eye-web/src/main/java/com/sohu/tv/hbase/eye/hbase/center/impl/AppImportServiceImpl.java
no changes added to commit (use "git add" and/or "git commit -a")

(1) 切到dev: git checkout develop

1
2
3
git add -A
git commit -m "xx develop"
git push

(2) 切到master: git checkout master

1
2
3
git add -A
git commit -m "xx master"
git push

(3) 合并: git checkout master

1
2
3
4
5
6
7
git merge develop
发生冲突
git status
git mergetool
git add -A
git commit "deal conflict"
git push

二、设置用户和邮箱

1
2
git config user.name "geekyijun"  
git config user.email "geekyijun@hotmail.com"