Answer the question
In order to leave comments, you need to log in
Git merge, why are branches not merged?
I'm just learning, so I may not fully understand the logic of git.
Essence.
1) create local repository
2) create file 1.txt
3) commit to master branch
4) create dev branch and switch to it
5) create file 2.txt
6) delete file 1.txt
7) commit to dev
8) after that, the master branch contains the 1.txt file, and the 2.txt file in the dev branch
9) Actually, the most important thing. While on the dev branch, I do a git merge master. And I get a message: "Already up-to-date."
The question is why the 1.txt file from the master branch is not pulled into the dev branch ??
Answer the question
In order to leave comments, you need to log in
I hope you have already read this.
Merging merges changes, not files. That is, the last common ancestor is taken and changes from both branches are applied to it.
In your case, the common ancestor is the commit in master (only the 1.txt file). There are no changes in the master branch after this commit, but there are in the dev branch. Namely, removing 1.txt and creating 2.txt.
[master] = 1 коммит
[dev] = [master] + 1 коммит.
Соответственно, когда вы пытаетесь смержить master, гит вам справедливо говорит, что master в полном составе уже в dev.
А вы, вероятнее всего, хотите git checkout master -- 1.txt
Vadim Misbakh-Soloviev completely gave the correct answer. I just want to add that you need to master the command git status
. This command shows file modification statuses. And this is how they usually create a repository and make a dev branch and commit everything there, and then merge with master if necessary.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question