Skip to content

Instantly share code, notes, and snippets.

@ChristopherA
Last active April 20, 2020 01:50
Show Gist options
  • Save ChristopherA/7c5112e555b4b43ac135 to your computer and use it in GitHub Desktop.
Save ChristopherA/7c5112e555b4b43ac135 to your computer and use it in GitHub Desktop.
Git & Github tips

Git & Github Tips

How to restore a file to last version

Assuming you did not git add the file to the index, or git commit the file, then:

git checkout filename

Assuming you already executed a git add of the file to the index, but did not git commit it, then:

git reset HEAD filename
git checkout filename

Assuming you did have already executed a git commit of the file, then:

git checkout origin/master filename

Assuming you want to blow away all commits from your branch (VERY DESTRUCTIVE):

git reset --hard origin/master

Init Empty & Sign

git init
git commit -S -m “root” --allow-empty
git remote add origin <repo>
git push origin master


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment