Checking incoming and outgoing files inside branches without going to the master branch

Suppose I have 4 branches

Master Branch

Branch 1

Branch 2

Branch 3

      

I am currently in Branch 3 and I want to get all files from Branch 2 to Branch 3 without pushing the files to the master branch.
Is it possible?

+3


source to share


2 answers


  • Option 1 - Merge branch2 into branch 3

It will record the merge history in your branch3.



`git checkout <branch 3>
 git merge <branch 2>`

      

  • Option 2 - select the files you want in branch3

    git checkout <branch 3> git checkout <branch> -- path/to/files

+2


source


You can:

  • merge branch2 into branch 3

     git checkout branch3
     git merge branch2
    
          

  • or, depending on what you want, force branch3 to become branch2

    git checkout branch2
    git branch -f branch3 branch2
    git checkout branch3
    
          



(which would replace the history of branch 3 with one of the branches2)

In both cases, the commit to master will not change.

+2


source







All Articles