Skip to content

Don't delete completed labs

Daniel Cantos edited this page Jun 4, 2019 · 6 revisions

If you follow the instructions for the github PR process, it is easy to accidentally submit a PR that deletes another persons merged lab solution.

How this happens

git checkout master
git pull upstream master
git checkout feature
git rebase master  # merged labs will appear in your branch here
# Delete other peoples' lab directories
git push -f

This is the same as the go-course PR instructions, with the deleting of other peoples labs that can come between the rebase and the push. This is easy to do accidentally since this is a spot where some work can be done, and if done in an IDE, can make it annoying to see other peoples labs pop up.

How to avoid it

  1. Don't delete other peoples labs on your machine. You won't even notice the new labs if you work mainly in the terminal, but in an IDE you will see more and more lab solutions pop up over time, which is annoying and can make it tempting to delete them.
  2. Only commit changes to your lab directory. You can commit specific files with git add lab/username to add only changes in your lab. You can also check what will get committed with git status before a commit.

What to do if you accidentally commit that delete

The best way to undo a commit is to rebase your good commits.

  1. First use git log or inspect your branch on GitHub to find the bad commit
  2. Then on your branch, do the following
git rebase --onto commit-before-bad bad-commit branch-name

This will rebase your branch onto the last good commit and copy all your commits except the bad commit. You can read more about how this command works here. You will lose any changes you made on the bad commit, and will need to add, commit and push them again.