DEV Community

Maxine
Maxine

Posted on

3 2

Stop Struggling with Merging Branches and Use these Git Commands instead

Stop Conflicting Merge Requests and Use These Commands instead ⤵️

-Xtheirs

Using the -Xtheirs flag when running git rebase or git pull, will favor the incoming changes from the branch you are rebasing/pulling from. Doing this means you accept any incoming changes from the branch you are rebasing/pulling off of. Say goodbye to going through to accept them all manually. Here is an example of how the command can be used:

git rebase -Xtheirs <branch you are rebasing/accepting changes>
Enter fullscreen mode Exit fullscreen mode

or

git pull origin <branch you are rebasing/accepting changes> -Xtheirs
Enter fullscreen mode Exit fullscreen mode

-Xours

Similarly using the -Xours flag when running git rebase or git pull, will favor the YOUR changes when rebasing with another branch. Doing this means you are accepting and keeping YOUR changes while pulling or rebasing from another branch. Here is an example of how the command can be used:

git rebase -Xours <branch you are rebasing/accepting changes>
Enter fullscreen mode Exit fullscreen mode

or

git pull origin <branch you are rebasing/accepting changes> -Xours
Enter fullscreen mode Exit fullscreen mode

Conclusion

I hope this tiny tutorial helps make the tedious process of merging branches can be a tad bit easier. Let me know what you think of these commands!🌟

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay