Git ‘Er Done
1 min readMar 26, 2021
Version control is important. Not just for teams, but even for the lowly hobbyist. No one wants to lose hours of work! Start a new branch, work on a feature, and when it’s ready, merge it back into the project. Here’s a summary of Git Bash commands.
- ls // list
- git — help
PULL, COMMIT, PUSH
- git pull origin [branch]
- git add . // add all changes
- git commit -m “commit notes”
- git push origin [branch]
Branch Early & Often
- git branch [branch] // create a new branch
- git switch [branch] // switch the current branch
- git merge [branch] // merge [branch] into the current branch
Going Back in Time
- git log // list of commits (press “q” to get back to the command line)
- git checkout [hashcode] // make a previous commit the current “pseudo branch”
- git checkout -b [new-branch-name] [hashcode] // create a new branch from the old commit
NEVER DO THIS! (But Here’s How)
- git reset — hard [hashcode] // reset to an older commit
- git push — force origin [branch] // Revert back to the older commit. WARNING: Destroys all commits afterwards! Better to make a new branch form the old commit.