kristofer revised this gist . Go to revision
1 file changed, 4 insertions, 2 deletions
git-oops.md
@@ -1,8 +1,10 @@ | |||
1 | 1 | ## Rogue Coder? | |
2 | 2 | ||
3 | - | Working on your own and just want it to work? Follow these instructions below, they’ve worked reliably for me and many others for years. | |
3 | + | Working on your own passion project and just want it to work? Follow these instructions below, they’ve worked reliably for me for years. | |
4 | 4 | ||
5 | - | Working with others? Git is complicated. Read the comments below this answer, consider other answers, and discuss with your team before you do something rash. | |
5 | + | Working with others on a project? Git is complicated. | |
6 | + | Research and consider other answers, and discuss with your team _before you do something rash_. | |
7 | + | And these options are the definition of **rash**. | |
6 | 8 | ||
7 | 9 | ### Reverting Working Copy to Most Recent Commit | |
8 | 10 |
kristofer revised this gist . Go to revision
1 file changed, 1 insertion, 1 deletion
git-oops.md
@@ -30,4 +30,4 @@ git reset --hard | |||
30 | 30 | # Push your changes to respective branch | |
31 | 31 | git push -f | |
32 | 32 | ``` | |
33 | - | Credits go to a similar Stack Overflow question, Revert to a commit by a SHA hash in Git?. | |
33 | + | Credits go to a similar Stack Overflow question, [Revert to a commit by a SHA hash in Git?](https://stackoverflow.com/questions/1895059/revert-to-a-commit-by-a-sha-hash-in-git). |
kristofer revised this gist . Go to revision
1 file changed, 33 insertions
git-oops.md(file created)
@@ -0,0 +1,33 @@ | |||
1 | + | ## Rogue Coder? | |
2 | + | ||
3 | + | Working on your own and just want it to work? Follow these instructions below, they’ve worked reliably for me and many others for years. | |
4 | + | ||
5 | + | Working with others? Git is complicated. Read the comments below this answer, consider other answers, and discuss with your team before you do something rash. | |
6 | + | ||
7 | + | ### Reverting Working Copy to Most Recent Commit | |
8 | + | ||
9 | + | To revert to the previous commit, ignoring any changes: | |
10 | + | ``` | |
11 | + | git reset --hard HEAD | |
12 | + | ``` | |
13 | + | where HEAD is the last commit in your current branch | |
14 | + | ||
15 | + | ### Reverting The Working Copy to an Older Commit | |
16 | + | ||
17 | + | To revert to a commit that's older than the most recent commit: | |
18 | + | ``` | |
19 | + | # Resets index to former commit; replace '56e05fced' with your commit code | |
20 | + | git reset 56e05fced | |
21 | + | ||
22 | + | # Moves pointer back to previous HEAD | |
23 | + | git reset --soft HEAD@{1} | |
24 | + | ||
25 | + | git commit -m "Revert to 56e05fced" | |
26 | + | ||
27 | + | # Updates working copy to reflect the new commit | |
28 | + | git reset --hard | |
29 | + | ||
30 | + | # Push your changes to respective branch | |
31 | + | git push -f | |
32 | + | ``` | |
33 | + | Credits go to a similar Stack Overflow question, Revert to a commit by a SHA hash in Git?. |