git reset hard HEAD Revert your repo to last committed state git checkout

Git reset hard head revert your repo to last

This preview shows page 391 - 393 out of 517 pages.

git reset --hard HEAD Revert your repo to last committed state. git checkout commit -- [file] Restore a file, or if omitted the whole repo, to its state at commit (see Figure 10.5 for ways to refer to a commit besides its 40-digit SHA-1 hash). Can be used to recover files that were previously deleted using git rm . git revert commit Reverts the changes introduced by commit . If that commit was the result of a merge, effectively undoes the merge and leaves the current branch in the state it was in before the merge. Git tries to back out just the changes introduced by that commit without disturbing other changes since that commit, but if the commit happened a long time ago, manual conflict resolution may be required. Figure 10.3: When a merge goes awry, these commands can help you recover by undoing all or part of the merge. git blame [file] Annotate each line of a file to show who changed it last and when. git diff [file] Show differences between current working version of file and last committed version. git diff branch [file] Show differences between current version of file and the way it appears in the most recent commit on branch (see Section 10.5 ). git log [ref .. ref] [files] Show log entries affecting all files between the two commits specified by the ref s (which must be separated by exactly two dots), or if omitted, entire log history affecting those files. git log --since=” date files Show the log entries affecting all files since the given date (examples: ”25-Dec-2011” , ”2 weeks ago” ). Figure 10.4: Git commands to help track who changed what file and when. Many commands accept the option --oneline to produce a compact representation of their reports. If an optional [file] argument is omitted, default is “all tracked files.” Note that all these commands have many more options, which you can see with git help command . HEAD the most recently committed version on the current branch. HEAD˜ the prior commit on the current branch ( HEAD˜ n refers to the n ’th previous commit). ORIG_HEAD When a merge is performed, HEAD is updated to the newly-merged version, and ORIG_HEAD refers to the commit state before the merge. Useful if you want to use git diff to see how each file changed as a result of the merge. 1dfb2c˜2 2 commits prior to the commit whose ID has 1dfb2c as a unique prefix. The last commit prior to date (see Figure 10.4 for date format) on branch , where
Image of page 391
branch @{ date }” HEAD refers to the current branch. Figure 10.5: Convenient ways to refer to certain commits in Git commands, rather than using a full 40-digit commit-ID or a unique prefix of one. git rev-parse expr resolves any of the above expressions into a full commit-ID. Summary of merge management for small teams: 1. Small teams typically use a “shared-repo” model, in which pushes and pulls use a single authoritative copy of the repo. In Git, the authoritative copy is referred to as the origin repo and is often stored in the cloud on GitHub or on an internal company server.
Image of page 392
Image of page 393

You've reached the end of your free preview.

Want to read all 517 pages?

  • Spring '19
  • Dr.Marcos

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors