I have my main branch and another branch feature. I checked out feature committed my changes, and did git merge main. It said Already up to date, but none of the changes from main appear in feature. Am I doing the merge wrong?
CodePudding user response:
"Already up to date" isn't a description of the state after the command did something, it's a message printed instead of doing something: "Nothing needs to be done, because the branch is already up to date".
More specifically, it is saying that all the commits reachable from the local branch pointer called "main" are also reachable from the currently checked out commit. Or, roughly speaking, "everything on main is already on the current branch".
If you think there should have been something to merge, one possibility is that you are looking at a branch called "main" on some other copy of the repository - on Github, for instance. To reference that branch, you first "fetch" it and then reference the "remote-tracking branch" in the form "name-of-remote/name-of-branch". The default "remote" (alias for another repository) is called "origin", so the common sequence of commands is:
git fetch origin
git merge origin/main
The combination of fetch merge can be abbreviated with the "pull" command, like so:
git pull origin main
This too will say "Already up to date" if it can't see anything that needs merging.
CodePudding user response:
But why you want to merge main into feature after you have make changes in feature? That doesn‘t make any sense. I think, feature was created from main, and if you don‘t make any changes in main, there are nothing to git merge from main in feature.
Do you want to merge the changes from feature in main? Because the opposite way makes no sense in a declared situatio... Then git checkout main and git merge feature. Or create a Pull Request from feature to main and approve the changes. After this, the changes will also merged into main.
