Here are the steps to merge a branch into master in Git, with detailed commands:
- Make sure you are on the master branch:
git checkout master
- Fetch the latest changes from remote repository:
git fetch origin
- Update your local copy of the master branch:
git rebase origin/master
- Make sure the branch you want to merge into master is up-to-date:
git checkout <branch-to-merge>
- Fetch the latest changes on the branch you want to merge:
git fetch origin <branch-to-merge>
- Rebase the branch with the latest changes from remote repository:
git rebase origin/<branch-to-merge>
- Go back to the master branch:
git checkout master
- Finally, merge the branch into master:
git merge <branch-to-merge>
- Push the changes to remote repository:
git push origin master
For example, if you have a branch called “feature-1” and an ADO repo called “cloudiseasy”, you would run these commands:
git checkout master
git fetch origin
git rebase origin/master
git checkout feature-1
git fetch origin feature-1
git rebase origin/feature-1
git checkout master
git merge feature-1
git push origin master