(Let's not get sidetracked by the fact that git merge does not always merge!)Ī merge commit is simply a commit with at least two parents. Now that we know that Git works backwards, let's take a look at more complex history, including history that includes an actual merge commit. Since both are snapshots, whatever changed from the parent's snapshot to the child's, must be whatever the person who made the child commit actually did. To show a commit as a patch, Git just looks at the commit's parent's tree first, then at the commit's tree, and compares the two. When you have Git show you a commit, you can-in fact, you almost always-have Git show it as a patch, rather than as a snapshot. That's what: git log masterĭoes: it starts with the one commit identified by master, and shows it, and then shows the one commit's one parent, and then shows the one before that, and so on. Git just picks out each commit one at a time and shows it. It's easy to show linear history, starting at the end of time and ending at the start. Git calls A a root commit: a commit with no parent. This commit does not point anywhere-it can't, it was the first commit it cannot have a parent-so this is where the history ends (starts?), at the beginning of time. If we swap out real hash IDs for single letters, to make things easier, we get something like this: A <-B <-C <-D <-E <-F <-G <-masterĬommit G points back to commit F, which points back to E, and so on until we reach the very first commit, commit A. and commit 1234567 has inside it the hash ID of the commit that comes right before 1234567. If commit 1234567 is the tip of master, git log can show you commit 1234567. The branch name contains the hash ID of the last commit-the tip of the branch-and we say that the branch name points to that commit. We simply start with the latest commit, as identified by some branch name like master, and work backwards. When dealing with ordinary, non-merge commits, it's pretty straightforward to look at the history. The last thing that Git stores in a commit-the second thing, really, right after the tree-is a list of parent commits, by their unique hash IDs. It stores a log message-whatever you give it-so that Git can show that as well. This is true of merge commits as well: a merge commit, like any other commit, has a tree.Įach commit also stores your name (author and committer) and email address and time-stamp, so that Git can show these to you. The hash ID is actually just a cryptographic checksum of the commit's content.Įach commit stores (the hash ID of) a snapshot of files-Git calls this a tree. You see these in git log output, for instance. But by default, it drops a lot more than that, via something that git log calls History Simplification. For instance, it drops all commits that don't affect any of the files you have asked about. This synthetic process deliberately drops some commits. while in dir/sub, Git will synthesize a (temporary) file history, by extracting some sub-history from the real history-the set of commits. When you run a command like git log dir/sub/file.ext, or for that matter, git log dir/sub or git log. In Git, the history is the set of commits. If you're able to share the two revisions of this file, opening a connect bug or emailing them to me directly would help investigate further.The history isn't gone, Git just isn't showing it. If I had to guess, I would guess that there's a whitespace or line ending issue, because that's always a problem in Git. There's some bug here where Visual Studio is not calculating the similarity correctly.This file is very near the edge of similarity - say, Git has decided that the two revisions are 61% similar to each other and are thus a rename, while Visual Studio has decided that the two revisions are merely 59% similar, and thus are not a rename.I'd be curious why one reports this as a rename and the other does not. However, Visual Studio and Git for Windows should agree on these things, generally speaking. Since this is a heuristic, it's not guaranteed that this will be deemed to be a rename. If they are sufficiently similar, then Git will deem this a rename. Instead, this is calculated by comparing the file in the original commit to the file in the subsequent commit. Thus, there is no rename information in the repository's history. However, Git does not track changes between two commits - instead, it compares the snapshots of the commits to determine how files have changed. Here, I've renamed a single file from its original name to renamed, and made a change to the contents at the same time: Visual Studio does follow history between two commits to determine if a file is renamed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |