![]() ForĮxample: $ git config gc.pruneexpire "30 days" You may wish to configure a longer grace period for doomed commits. Or checkout the 5th-last visited commit via: $ git checkout the “Specifying Revisions” section of git help rev-parse for more. Instead of cutting and pasting hashes from the reflog, try: $ git checkout minutes ago}" The reflog command provides a friendly interface to these log files. The latter can be used to find hashes of commits on branches that have been accidentally lopped off. The subdirectory refs contains the history of all activity on all branches, while the file HEAD shows every hash value it has ever taken. Git records every hash of a commit it computes in. git/objects and use trialĪnd error to find the one you want. You could look at all the hash values in. Perhaps you’ve just realized you made a monumental mistake and you need to go back to an ancient commit in a long-forgotten branch.īy default, Git keeps a commit for at least two weeks, even if you ordered We place a snapshot of some, but not all, of our changes into the index, and then permanently record this carefully rigged snapshot. On this occasion, we want finer control, so we manipulate the index. Usually we can ignore the index and pretend we are reading straight from and writing straight to the history. ![]() ![]() a option only performs the second step, and only makes sense after runningĬommands that somehow change the index, such as git add. Step permanently records the snapshot now in the index. Snapshot of the current state of every tracked file into the index. Rather, Git first writesĭata to the index, and then copies the data in the index to its finalįor example, commit -a is really a two-step process. Git seldom shuttlesĭata directly between your project and its history. So far we have avoided Git’s famous index, but we must now confront it toĮxplain the above. Alternatively, run git commit -interactive which You can stage or unstage several files at a time, or review and select changes Interface is less straightforward, but more flexible. ![]() What if you’ve edited many files in many places? Reviewing each change one by You omit the -a option, otherwise Git will commit all the edits. To commit precisely the changes you selected (the staged changes). Have other options, such as postponing the decision type "?" to learn more. Have you neglected to commit for too long? Been coding furiously and forgottenĪbout source control until now? Made a series of unrelated changes, becauseįor each edit you made, Git will show you the hunk of code that was changed,Īnd ask if it should be part of the next commit. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |