How to move the current working branch to master branch in git

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?


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.


Do you want to merge a 'develop' branch into master?

git checkout master
git merge develop

Or do you want to merge the changes from master into your development branch?

git checkout develop
git merge master