标签:merge 编辑器 TE -- 文件的 git log 参数 hang https
mike@win10-001 MINGW64 ~/cookbook/cookbook (master)
$ git branch first-branch
mike@win10-001 MINGW64 ~/cookbook/cookbook (master)
$ git checkout first-branch
Switched to branch ‘first-branch‘mike@win10-001 MINGW64 ~/cookbook/cookbook (first-branch)
mike@win10-001 MINGW64 ~/cookbook/cookbook (first-branch)
$ git checkout -b first-branch
mike@win10-001 MINGW64 ~/cookbook/cookbook (first-branch)
$ echo "Change" >> README.md
$ git commit -a -m ‘Readme changed‘
warning: LF will be replaced by CRLF in README.md.
The file will have its original line endings in your working directory.
[first-branch dc7b6d5] Readme changed
1 file changed, 1 insertion(+)
mike@win10-001 MINGW64 ~/cookbook/cookbook (first-branch)
$ git push -u origin first-branch
Counting objects: 3, done.
Writing objects: 100% (3/3), 262 bytes | 131.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote:
remote: To create a merge request for first-branch, visit:
remote: http://gitlab.aishangwei.net/root/cookbook/merge_requests/new?merge_request%5Bsource_branch%5D=first-branch
remote:
To gitlab.aishangwei.net:root/cookbook.git
* [new branch] first-branch -> first-branch
Branch ‘first-branch‘ set up to track remote branch ‘first-branch‘ from ‘origin‘.
$ git checkout master
Switched to branch ‘master‘
Your branch is up to date with ‘origin/master‘.
$ git merge first-branch –no-ff
mike@win10-001 MINGW64 ~/cookbook/cookbook (master)
$ git merge first-branch --no-ff
Merge made by the ‘recursive‘ strategy.
README.md | 1 +
1 file changed, 1 insertion(+)
mike@win10-001 MINGW64 ~/cookbook/cookbook (master)
$ git push origin master
Counting objects: 1, done.
Writing objects: 100% (1/1), 223 bytes | 223.00 KiB/s, done.
Total 1 (delta 0), reused 0 (delta 0)
To gitlab.aishangwei.net:root/cookbook.git
53ec2ca..5e1ebdd master –> master
mike@win10-001 MINGW64 ~/cookbook/cookbook (master)
$ git push origin --delete first-branch
To gitlab.aishangwei.net:root/cookbook.git
- [deleted] first-branch
当我们长时间的运行在分支上的话,我们有时想要同步master,可以通过合并到master后,再切换到我们所在的分支,Git有一个更好的方式来这个,叫做rebasing。 在rebasing中,相当于把你当前的branch分支合并到master,并同步master状态。不过是一步完成了。
mike@win10-001 MINGW64 ~/cookbook/cookbook (master)
$ git checkout -b rebase-branch
Switched to a new branch ‘rebase-branch‘
mike@win10-001 MINGW64 ~/cookbook/cookbook (rebase-branch)
$ echo "File content" >> another_file.mdmike@win10-001 MINGW64 ~/cookbook/cookbook (rebase-branch)
$ git add .
warning: LF will be replaced by CRLF in another_file.md.
The file will have its original line endings in your working directory.mike@win10-001 MINGW64 ~/cookbook/cookbook (rebase-branch)
$ git commit -m ‘Another commit‘
[rebase-branch c20f042] Another commit
1 file changed, 1 insertion(+)
create mode 100644 another_file.md
mike@win10-001 MINGW64 ~/cookbook/cookbook (rebase-branch)
$ git checkout master
Switched to branch ‘master‘
Your branch is up to date with ‘origin/master‘.
$ git push origin rebase-branch –f
mike@win10-001 MINGW64 ~/cookbook/cookbook (master)
$ echo "1" >> README.mdmike@win10-001 MINGW64 ~/cookbook/cookbook (master)
$ git add .
warning: LF will be replaced by CRLF in README.md.
The file will have its original line endings in your working directory.mike@win10-001 MINGW64 ~/cookbook/cookbook (master)
$ git commit -m ‘Commit in master‘
[master acb491e] Commit in master
1 file changed, 1 insertion(+)
mike@win10-001 MINGW64 ~/cookbook/cookbook (rebase-branch)
$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: Another commit
在开发的时候可能由于频繁的提交信息,比较零散和片断,比如在提交多少次后,想做一个总结。这时候可以把前面几个合并成一个提交信息。
执行案例:
mike@win10-001 MINGW64 ~/cookbook/cookbook (rebase-branch)
$ git checkout -b squash-branch
Switched to a new branch ‘squash-branch‘
mike@win10-001 MINGW64 ~/cookbook/cookbook (squash-branch)
$ echo "1" >> README.mdmike@win10-001 MINGW64 ~/cookbook/cookbook (squash-branch)
$ git add .
warning: LF will be replaced by CRLF in README.md.
The file will have its original line endings in your working directory.mike@win10-001 MINGW64 ~/cookbook/cookbook (squash-branch)
$ git commit -a -m ‘wip1‘
[squash-branch 4e54db8] wip1
1 file changed, 1 insertion(+)mike@win10-001 MINGW64 ~/cookbook/cookbook (squash-branch)
$ echo "2" >> README.mdmike@win10-001 MINGW64 ~/cookbook/cookbook (squash-branch)
$ git add .
warning: LF will be replaced by CRLF in README.md.
The file will have its original line endings in your working directory.mike@win10-001 MINGW64 ~/cookbook/cookbook (squash-branch)
$ git commit -a -m ‘wip2‘
[squash-branch 5d37a65] wip2
1 file changed, 1 insertion(+)
mike@win10-001 MINGW64 ~/cookbook/cookbook (squash-branch)
$ git log --oneline
5d37a65 (HEAD -> squash-branch) wip2
4e54db8 wip1
f5f7fde (rebase-branch) Another commit
acb491e (master) Commit in master
5e1ebdd (origin/master) Merge branch ‘first-branch‘
dc7b6d5 (first-branch) Readme changed
53ec2ca Added readme file
$ git rebase –i HEAD~2
注解: HEAD~2 代表着我们想挤压最后两个提交。假如你想要挤压最后4个提交,那么使用HEAD~4
原始:
改变后:
$ git rebase -i HEAD~2
[detached HEAD 48f7dae] Added two number to the readme
Date: Sun Jun 24 17:33:08 2018 +0800
1 file changed, 2 insertions(+)
Successfully rebased and updated refs/heads/squash-branch.
$ git push origin squash-branch
Counting objects: 9, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (9/9), 839 bytes | 104.00 KiB/s, done.
Total 9 (delta 0), reused 0 (delta 0)
remote:
remote: To create a merge request for squash-branch, visit:
remote: http://gitlab.aishangwei.net/root/cookbook/merge_requests/new?merge_request%5Bsource_branch%5D=squash-branch
remote:
To gitlab.aishangwei.net:root/cookbook.git
* [new branch] squash-branch -> squash-branch
标签:merge 编辑器 TE -- 文件的 git log 参数 hang https
原文地址:https://www.cnblogs.com/zangxueyuan/p/9221207.html