12/14/2023 0 Comments Git reset to commit hashTo get the list of the most recent five commits, navigate to the main directory of your repository and execute the git log command as below: git log -5 -oneline I’m going to pick one of my most recent commits that has a change that I made, as opposed to a merge, just to narrow down the set of changes I want to look at. Simply follow the steps below, substituting in your hashes for the ones I have in my repository. Note: The commit hashes I’ll use will be different than the ones in your repository. You’ll start walking down the tree to see how Git stores and tracks your work. Since the atomic particle of Git workflow is the commit, it makes sense to start there. git directory and see what’s inside of each. To see this in action, you’ll dissect the “secret” files underneath the. In fact, a lot of what Git does is create references to references in a tree-like structure to store and retrieve your data, and its metadata, as quickly and efficiently as possible. There’s no ambiguity there.īut if you dig down a little bit, the commit hash doesn’t reference everything that has to do with a commit. The hash is the key that points to a particular commit in the repository, and it’s pretty clear to see that it’s just a type of unique ID. You’ve seen that many times over, both in this book and in your personal and professional work with Git. Git refers to all commits by their SHA-1 hashes. But it’s a useful point to start when you want to know how Git works. Well, not everything is a hash, to be honest. If you don’t have one handy, you can use one of the repos provided with the materials for this book. To follow along, you can start with any repository. But being aware of how Git manages your repository will help cement that mental model and give a little more insight into why Git does what it does. The nice thing about Git is that you could spend your entire career not knowing how the Git internals work, and you’d get along quite well. The front end does an excellent job of mirroring the mental model of what’s happening to your code.īut as you would expect, a lot is going on underneath. To push commits from your local repository to the remote repository, you execute git push. To commit your changes in your local repository, you execute git commit. To pull changes from the remote down to the local, you execute git pull. Git is one of those wonderful, elegant tools that does an amazing job of abstracting the underlying mechanism from the front-end workings. Section I: Advanced Git Section 1: 7 chapters Show chapters Hide chaptersĢ.8 Challenge: Resolve another merge conflictģ.6 Challenge: Clean up the remaining stashĤ.8 Challenge: Rebase on top of another branchĥ.9 Challenge 2: Rebase your changes onto mainĦ.7 Using filter-branch to rewrite historyĦ.8 Challenge: Remove IGNORE_ME from the repositoryħ.2 Working with the three flavors of reset
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |