DEV Community

loading...

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

fernand0 profile image Fernando Tricas García ・1 min read

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

Discussion (0)

pic
Editor guide