If we'd used regular git merge-with -no-ff the first time, since otherwise Git would have cheated with a fast-forward instead of a merge-we'd have, at this point, this graph: C_ <- another-branch The git branch -d command will refuse to delete it as commit C is not an ancestor of current commit E. The same goes for commit C, find-able only through the name another-branch. Git won't discard the name, and hence lose the commit, unless you force it. Since Git is all about commits, losing a commit would be bad. (Remember, B stands in for some random-looking hash ID that we would never be able to guess.) If we do delete the name new-branch, we will lose commit B. In fact, the name new-branch is the only way we have to find commit B. That's true we will not find B in a walk from E back to the root. What this is telling you is that from commit E-where you are now-there's no way to find commit B. This makes new commit/snapshot E, so let's draw that: C error: The branch 'new-branch' is not fully merged. Since it is a squash-merge, rather than a real merge, once again we do not have a backwards link to commit C, even though we used commit C to do the merge: $ git commit -m "Squash another-branch" The last step here is to commit the merge. (you can substitute whatever you want for the merge result in the here-document section before the END). This creates third commit C, dragging the name another-branch forward to it: C ans This creates new commit B, dragging the name new-branch forward: A > ans The repository now has one named branch, master, which holds the hash ID of this one commit A, so we can draw it like this: A > ans That one commit has some big ugly hash ID, but I'll just use the letter A to stand in for it. You now have a repository with exactly one commit in it. Using your example, creating a new empty repository and stopping at this point: $ git commit -m "First commit" Git isn't really very much concerned about branches either: it's still all about commits. Git isn't really concerned with files, as it's about commits. In particular, if you use a plain git merge (with -no-ff if/when required), Git records the commits. You can get several things that may or may not be good enough. How can I tell whether the branches have been merged? The two branches do not appear in the list of merged branches, so this didn't work either. Trying to use git diff: $ git diff new-branchĪll the statements above yield a non-empty diff. I could use option -D, but usually someone else merges my stuff, and I want to check > If you are sure you want to delete it, run 'git branch -D another-branch'. > error: The branch 'another-branch' is not fully merged. > If you are sure you want to delete it, run 'git branch -D new-branch'. > error: The branch 'new-branch' is not fully merged. I should be able to delete them now, right? Unfortunately, no: $ git branch -d new-branch $ git commit -m "Commit on another-branch"īoth branches have been merged. To reproduce, create a new git repository: $ mkdir tmpĬreate branch new-branch with commits: $ git checkout -b new-branchĬreate branch another-branch with commits: $ git checkout master How can I quickly check this with existing git commands? To determine whether a branch has been fully merged. As mentioned in the other Stack Overflow question, there's more information about this in the Maintenance and Data Recovery section on merging branches with -squash, git does no longer seem to be able Non-accessible commits are eventually removed when git performs garbage collection in the repository. To delete the tag locally, and also delete the tag from GitHub using: git push origin :refs/tags/TAG-NAME You could use for example gitk -all to show all branches and tags in your local repository, and if you see tags that were on the old branch that you have now deleted, you could delete each tag as well, using git tag -d TAG-NAME If you created tags on the branch and pushed those tags to GitHub, then the tags will still exist in your local repository, so commits accessible from those tags won't ever be deleted. See this question for example: Git: what is a dangling commit/blob and where do they come from? Commits that can't be accessed from existing branches or tags are called dangling commits. Yes, git will keep some non-accessible remnants - at least to begin with.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |