项目作者: sabmeua

项目描述 :
Easy to merge git conflicts to accept both changes.
高级语言: Shell
项目地址: git://github.com/sabmeua/git-accept.git
创建时间: 2019-12-04T05:21:10Z
项目社区:https://github.com/sabmeua/git-accept

开源协议:

下载


git-accept

Easy to merge git conflicts to accept both changes.

CircleCI

What’s this

When git merge/rebase shows you that it couldn’t resolve all of your conflicts automatically,
you will try to solve using git checkout with option --theirs , --ours or manually edit with git mergetool.

However, sometimes you may want to simply adopt both changes. In that case if using an editor like Atom or VSCode,
it can choose the menu to solve it but there isn’t in git cli. This is a simple git extension subcommand that does just that.

Example

If there is a conflict as follows.

  1. $ git diff file
  2. diff --cc file
  3. index b414108,9f9a0f9..0000000
  4. --- a/file
  5. +++ b/file
  6. @@@ -1,6 -1,6 +1,11 @@@
  7. 1
  8. 2
  9. ++<<<<<<< HEAD
  10. +3
  11. +4
  12. ++=======
  13. +
  14. +
  15. ++>>>>>>> develop
  16. 5
  17. 6

It can merge like this with git accept.

  1. $ git accept theirs file
  2. $ cat file
  3. 1
  4. 2
  5. 5
  6. 6
  7. $ git accept ours file
  8. $ cat file
  9. 1
  10. 2
  11. 3
  12. 4
  13. 5
  14. 6
  15. $ git accept theirs-then-ours file
  16. $ cat file
  17. 1
  18. 2
  19. 3
  20. 4
  21. 5
  22. 6
  23. $ git accept ours-then-theirs file
  24. $ cat file
  25. 1
  26. 2
  27. 3
  28. 4
  29. 5
  30. 6

Usage

  1. git accept <merge plan> <file>

Available merge plans

  • ours, 2 : Accept incoming changes. alias of git checkout --ours, git checkout -2.
  • theirs, 3 : Accept current changes. alias of git checkout --theirs, git checkout -3.
  • ours-then-theirs, 23 : Accept both current and incoming changes in the order of ours, theirs.
  • theirs-then-ours, 32 : Accept both current and incoming changes in the order of theirs, ours.
  • cancel : Discard local changes and revert to conflict. alias of git checkout -m.

Instration

Place git-accept in your PATH and add +x permission, and git will make it available as a accept subcommand.
If you no longer need it, simply remove the file.