I have currently one of the project it contain more branches. master branch not yet merger long time. So i want switched to master with latest code.
Can you please give me necessary commands and steps.
Let me re-frame my question.
I am working in a project with different branches. The latest changes were in some branch other than master. Now my requirement is: is there a way to move the current working branch to master without merging it with master, to avoid conflicts?
The git branch command can be used to create a new branch. When you want to start a new feature, you create a new branch off main using git branch new_branch . Once created you can then use git checkout new_branch to switch to that branch.
If you want to have in master exactly the same files state as in other_branch and save history - do the following (and note the period at the end):
git checkout master git checkout other_branch .
Now you will have a full copy of other_branch in current master (it is softer than reset
), not yet committed. Then make a regular commit:
git add --all git commit -m "* copy other_branch to master working tree"
Note: untracked (unindexed) files (directories) from other_branch will remain, if they are not tracked by master. To remove those untracked files (directories):
git clean -fd
See How to remove local (untracked) files from the current Git working tree? for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With