git branch

git basic branch


git branch <branchName>#create branch
git branch --list#show branch list,
git checkout <branchName>#choose branch,HEAD is pointer of the current branch last commit

create a file in branch 0.0.1,then checkout master ,merge 0.0.1

git checkout 0.0.1
echo "b">b.txt
git add b.txt
git commit -m "add b.txt"
git checkout master
git merge 0.0.1

git alias

huskyui@ubuntu:~/Desktop/git/lesson07$ git log --graph --decorate --oneline
* 89f9c31 (HEAD -> master, 0.0.1) add b
* 4ed2d10 3
* 96d5837 2
* 26abdbb 1
* c85c670 inital commit

use alias

huskyui@ubuntu:~/Desktop/git/lesson07$ git config --local alias.tree 'log --graph --decorate --oneline'
huskyui@ubuntu:~/Desktop/git/lesson07$ git tree
* 89f9c31 (HEAD -> master, 0.0.1) add b
* 4ed2d10 3
* 96d5837 2
* 26abdbb 1
* c85c670 inital commit

checkout -b

git checkout -b iss53
#Switched to a new branch "iss53"
# git branch iss53
# git checkout iss53

merge conflict

huskyui@ubuntu:~/Desktop/git/lesson08$ echo "hellowoold">c.txt
huskyui@ubuntu:~/Desktop/git/lesson08$ git add .
huskyui@ubuntu:~/Desktop/git/lesson08$ git commit -m"master commit c.txt"
[master 430916b] master commit c.txt
 1 file changed, 1 insertion(+)
 create mode 100644 c.txt
huskyui@ubuntu:~/Desktop/git/lesson08$ git checkout dev
Switched to branch 'dev'
huskyui@ubuntu:~/Desktop/git/lesson08$ ls
a.txt  b.txt
huskyui@ubuntu:~/Desktop/git/lesson08$ echo "helloworld">c.txt
huskyui@ubuntu:~/Desktop/git/lesson08$ git add .
huskyui@ubuntu:~/Desktop/git/lesson08$ git commit -m"dev commit c.txt"
[dev 01a61b3] dev commit c.txt
 1 file changed, 1 insertion(+)
 create mode 100644 c.txt
huskyui@ubuntu:~/Desktop/git/lesson08$ git checkout master
Switched to branch 'master'
huskyui@ubuntu:~/Desktop/git/lesson08$ git merge dev
Auto-merging c.txt
CONFLICT (add/add): Merge conflict in c.txt
Automatic merge failed; fix conflicts and then commit the result.
huskyui@ubuntu:~/Desktop/git/lesson08$ git status
On branch master
You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)

Unmerged paths:
  (use "git add <file>..." to mark resolution)

	both added:      c.txt

no changes added to commit (use "git add" and/or "git commit -a")
huskyui@ubuntu:~/Desktop/git/lesson08$ vi c.txt
huskyui@ubuntu:~/Desktop/git/lesson08$ git add c.txt
huskyui@ubuntu:~/Desktop/git/lesson08$ git commit -m "fixed conflict"
[master 2e602f6] fixed conflict
huskyui@ubuntu:~/Desktop/git/lesson08$ git diff master..dev
huskyui@ubuntu:~/Desktop/git/lesson08$ git merge dev
Already up to date.
huskyui@ubuntu:~/Desktop/git/lesson08$ git branch --list
  dev
* master
huskyui@ubuntu:~/Desktop/git/lesson08$ git checkout dev
Switched to branch 'dev'
huskyui@ubuntu:~/Desktop/git/lesson08$ git merge master
Updating 01a61b3..2e602f6
Fast-forward

abort merge

huskyui@ubuntu:~/Desktop/git/lesson08$ git merge dev
Auto-merging c.txt
CONFLICT (content): Merge conflict in c.txt
Automatic merge failed; fix conflicts and then commit the result.
huskyui@ubuntu:~/Desktop/git/lesson08$ git merge --abort
huskyui@ubuntu:~/Desktop/git/lesson08$ git status
On branch master
nothing to commit, working tree clean
huskyui@ubuntu:~/Desktop/git/lesson08$ git diff master..dev
diff --git a/c.txt b/c.txt
index 74b0666..1d8e2de 100644
--- a/c.txt
+++ b/c.txt
@@ -1 +1 @@
-helloworlxajsdjsads  d
+hsdfelloworld
huskyui@ubuntu:~/Desktop/git/lesson08$ git merge dev
Auto-merging c.txt
CONFLICT (content): Merge conflict in c.txt
Automatic merge failed; fix conflicts and then commit the result.
huskyui@ubuntu:~/Desktop/git/lesson08$ ls
a.txt  b.txt  c.txt
huskyui@ubuntu:~/Desktop/git/lesson08$ git merge dev
error: Merging is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.

delete branch

git branch -d dev#delete branch dev
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值