Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 1.12 KB

README.md

File metadata and controls

24 lines (19 loc) · 1.12 KB

Me Learning Git

This is just a test repo to try different Git and Github related things out.

Reset github repo to an earlier state via local repo

Sometimes I want to actually rewind a few steps in the repo history, usually for tidiness. Note that this is permanent!

  1. Do a hard reset to a specific commit id git reset --hard 1234abc
  2. Local will now say that there are commits to pull from origin (github) - do not pull these
  3. Force push from local to github git push -f origin master
  4. Local and origin (github) should now be identical

Stash current edits and move them to a new branch

Often I realise my current work would have been better in a new branch:

  1. Stash current edits git stash push
  2. Create a new branch and unstash edits git stash branch nameofnewbranch

Stash current edits, switch to an existing branch, and unstash

Often I realise my current work would have been better in a different branch that already exists:

  1. Stash current edits git stash push
  2. Switch to a different branch
  3. Unstash edits git stash pop

Stash current edits including untracked (new) files

git stash push -u