So, you want to merge just some changes from another git branch?
Fernando Tricas García

Fernando Tricas García @fernand0

About: El mundo es imperfecto. Puedes hacer algo para mejorarlo. O no. Puede que lo consigas. O no.

Location:
Zaragoza, Spain
Joined:
Mar 6, 2020

So, you want to merge just some changes from another git branch?

Publish Date: Feb 15 '21
0 0

I'm working on a separate development branch but I've discovered that, maybe, some changes could be integrated in the main branch (but not all of them). What can I do?
There are several solutions in How can I selectively merge or pick changes from another branch in Git?, but I've found easy to follow and convenient the following one:

"Let’s say you have the master, exp1, and exp2 branches. You want to merge one file from each of the experimental branches into master. "

git checkout master 
git checkout exp1 path/to/file_a
git checkout exp2 path/to/file_b

# Save these files as a stash
git stash

# Merge stash with master
git merge stash
Enter fullscreen mode Exit fullscreen mode

Comments 0 total

    Add comment