![]() ![]() Any commits after that point are no longer on your branch. Git will start there and work backwards through time to find all the earlier commits. The one commit your branch named before? Well, that one no longer matters much: the branch name now names the commit you picked out. You can now pick any commit you like, use your mouse to cut-and-paste its ID, and use git reset to make your current branch name that one particular commit. Use git log -all -decorate -oneline -graph to get a really big view of every commit in your repository, including their shortened hash IDs. ![]() When you use git reset -soft, git reset -mixed, or git reset -hard, you get to pick out any commit you like, anywhere in your repository. All other commits that are on the branch are found by starting 1 at this one commit and working backwards. Your current branch name, such as master or testing, currently identifies one specific commit. This is the first step of any of these kinds of git reset. If you use git reset -soft, Git skips this step.Ĭhange the commit identified by your current branch name. This is actually the second step of git reset -hard. Doing a git reset -hard tells your Git: Make all the index copies of files match the commit copies. Git also calls the index the staging area-these are two terms for the same thing. Your Git keeps a copy of all of your current files in its index. If you use git reset -mixed or git reset -soft, Git skips this step. This is actually the last step of git reset -hard. Your work-tree is where your Git puts the files you can see and work with. When you do a git reset -hard in your repository, you: Nothing you do in your repository affects them at all until you have your Git call up their Git and ask it or tell it: make some change(s). Not immediately for sure, because your repository is your repository, and their repository-the online one-is their repository. ![]() So if I do a hard reset, would that also have an effect on the files in the online repo? Meanwhile, to answer the question you did ask: Git will compare the snapshots in the commits specified by the two hashes, and show you what's different in those two commit snapshots. Then, using your mouse to cut and paste the hashes, because commit hash IDs are way too hard to use otherwise, run: git diff Use git log to show your current commit, including its full hash ID, and previous commits, including their full hash IDs. You can also- at any time, regardless of branches-use git diff on any two commits to compare them. That puts your work-tree back to the way it should be to work with the latest commit on the named branch, while also putting you on the named branch. To exit "detached HEAD" mode, pick any branch name and use git checkout name. Instead, you have checked out some historical commit, which you can now see and work with in your work-tree. In detached HEAD mode, you are on no branch at all. Since you mostly want, at the moment, to look at a past commit, you probably should just check out that commit as a "detached HEAD". ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |