Skip to content

Commit

Permalink
Simplify basic revert
Browse files Browse the repository at this point in the history
close #177
  • Loading branch information
RandomSort committed Apr 29, 2020
1 parent 50cea38 commit 91caf93
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
38 changes: 18 additions & 20 deletions basic-revert/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,24 @@

## The task

You again live in your own branch, this time we will revert some change on a branch.
In this task a few changes snuck in, that we'd like to get out. Our history is public, so we can't just change it. Rather we need to use revert to remove the unwanted changes in a safe way.

1. Use `git log --decorate --oneline` to look at the history
2. Use `cat` to view the content of `greeting.txt`
3. Use `git revert` on the newest commit, to remove the changes the last commit added
4. Use `git log --decorate --oneline` to view the history
5. Did the revert command add or remove a commit?
6. Use `cat` to view the content of `greeting.txt`
7. Use `ls` to see the content of the workspace
8. Use `git log --decorate --oneline` to find the sha of the commit adding credentials to the repository
9. Use `git revert` to revert the commit that added the credentials
10. Use `git log --decorate --oneline` to view the history
11. Use `ls` to see the content of the workspace
12. How many commits were added or changed by the last revert?
13. Use `git show` with the sha of the commit you reverted to see that the credentials file is stilll in the history

1. Create a branch called `reverting`
2. Checkout the branch
3. What is the output of `git branch`?
4. What is the output of `git log --oneline --graph --all`
5. Use `cat` to see the contents of the greetings
6. Revert the latest change, so you get the original content in the file
7. Use `cat` to see the contents of the greetings
8. Diff the branches

## Useful commands
- `git branch`
- `git branch <branch-name>`
- `git branch -d <branch-name>`
- `git checkout`
- `git branch -v`
- `git add`
- `git commit`
- `git commit -m`
- `git revert <sha1>`
- `git diff <branchA> <branchB>`
- `git log --oneline --graph --all`
- `git revert <ref>`
- `git log --decorate --oneline`
- `git show <ref>`
10 changes: 7 additions & 3 deletions basic-revert/setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ Set-Content -Value "" -Path greeting.txt
git add greeting.txt
git commit -m "Add file greeting.txt"

Set-Content -Value "we want to revert back to this" -Path greeting.txt
Set-Content -Value "supersecretpassword" -Path credentials.txt
git add credentials.txt
git commit -m "Add credentials to repository"

Set-Content -Value "Original File Content" -Path greeting.txt

git add greeting.txt
git commit -m "Add content to greeting.txt"

Set-Content -Value "this should have been appended to the original content" -Path greeting.txt
Set-Content -Value "This should have been appended to the original content, rather than overwriting it" -Path greeting.txt

git add greeting.txt
git commit -m "Add more content to greeting.txt"
git commit -m "Overwrite greeting.txt"
11 changes: 7 additions & 4 deletions basic-revert/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ pre-setup # Make exercise repo, and setup necessary.
touch greeting.txt
git add greeting.txt
git commit -m "Add file greeting.txt"
echo "we want to revert back to this" > greeting.txt
echo "supersecretpassword" > credentials.txt
git add credentials.txt
git commit -m "Add credentials to repository"
echo "Original file content" > greeting.txt
git add greeting.txt
git commit -m "Add content to greeting.txt"
echo "this should have been appended to the original content" > greeting.txt
echo "This should have been appended to the original content, rather than overwriting it." > greeting.txt
git add greeting.txt
git commit -m "Add more content to greeting.txt"
git commit -m "Overwrite greeting.txt"

post-setup
post-setup

0 comments on commit 91caf93

Please sign in to comment.