12/23/2023 0 Comments Finding head commit id in smartgit![]() Now Git: you have files, a working tree, an index, a local repository, a remote repository, remotes (pointers to remote repositories), commits, treeishes (pointers to commits), branches, a stash… and you need to know all of it. In fact, branches are tags, and files you already know about, so you really need to learn three new things. That’s pretty much everything you need to know. As a point of reference, consider Subversion: you have files, a working directory, a repository, versions, branches, and tags. The information model is complicated – and you need to know all of it. What a pity that it’s so hard to learn, has such an unpleasant command line interface, and treats its users with such utter contempt. It has a powerful distributed model which allows advanced users to do tricky things with branches, and rewriting history. However, other users sharing the branch can be confused if the branch is shared on remote repositories.Git is the source code version control system that is rapidly becoming the standard for open source projects. The consequences of any "accident" can be reverted by using the proper commit. Resets on local branches are usually harmless. Unreferenced commits remain in the repository until the garbage collection software is run by system. They would still be in the repository if we did not tag them, but then we could reference them only by their hash names. They are not listed in the master branch anymore but still remain in the repository. We can see that the wrong commits are not gone. * 45fa96b | Revert "Oops, we didn't want this commit" (oops) Run: git hist -all Result: $ git hist -all At the beginning of the lesson, we created the "oops" tag for the canceled commit. What happened to the wrong commits? They are still in the repository. The -hard parameter makes the working directory reflect the new branch head. Our master branch is pointing at commit v1 and the "Revert Oops" and "Oops" commits no longer exist in the branch. * fa3c141 | Added HTML header (HEAD, v1, master) As the branch has a tag, we can use the tag name in the reset command (if it does not have a tag, we can use the hash value). In the history log above, the commit tagged "v1" is before the "Oops" and "Revert Oops" commits. Run: git tag oops 04 Reset commit to previous Oops Let us mark the last commit with tag, so you can find it after removing a commit(s). Let us remove them with the reset command. We see the last two commits in this branch are "Oops" and "Revert Oops". * 8c32287 | Added standard HTML page tags (v1-beta) * 846b90c | Oops, we didn't want this commit * 45fa96b | Revert "Oops, we didn't want this commit" (HEAD, master) Let us do a quick scan of our commit history. Optionally reset the working directory so it will match the specified commit.Optionally reset the buffer zone so it will comply with the specified commit.Overwrite the current branch so it will point to the correct commit.When a commit reference is given (ie, a branch, hash, or tag name), the reset command will. We have already used the reset command to match the buffer zone and the selected commit (HEAD commit was used in the previous lesson). This command would prevent the appearance of one or more unwanted commits in the git log history. It would be nice to have an undo command which allows the incorrect commit(s) to be immediately deleted. Often after a commit is already made, we realize it was a mistake. However, both original and cancelled commits are seen in the history of the branch (when using git log command). Revert is a powerful command of the previous section that allows you to cancel any commits to the repository. To learn to delete the branch's latest commits.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |