Checking in and out files within branches without moving to the Master Branch
Assume that I have 4 branches
Master Branch Branch 1 Branch 2 Branch 3
I am currently in Branch 3 and I want to get all the files from Branch 2 to Branch 3 without committing the files to Master branch.
Is that possible?
2 Solutions collect form web for “Checking in and out files within branches without moving to the Master Branch”
- Option 1 – Merge branch2 into branch3
It will record the merging history in your branch3.
`git checkout <branch 3> git merge <branch 2>`
Option 2 – Fetch the files you want into branch3
git checkout <branch 3>
git checkout <branch> -- path/to/files
You could either:
merge branch2 to branch3
git checkout branch3 git merge branch2
or, depending on what you need, force branch3 to become branch2
git checkout branch2 git branch -f branch3 branch2 git checkout branch3
(that would replace the history of branch3 by the one of branch2)
In both cases, commits on master would be unchanged.