After the first post on Git 101, here is a set of commands you will use after the first 15-20 minutes of working with it. Some are very useful (e.g. stash your work before you can commit it in order to go for a quick coffee when your code is not done) and some are a quite rare (e.g. setting up a git on a remote server). Good luck.
Update & Merge
Creating a branch (and switching to the new branch) in one line
git checkout -b "The new branch name"
- git pull – to update your local repository to the newest commit. It will fetch and merge remote changes.
- git merge – to merge another branch into your active branch (e.g. master).
Remember that in both cases, git tries to auto-merge changes. IF you have conflicts, You are responsible to merge those conflicts manually by editing the files shown by git. After changing, you need to mark them as merged with
git add - Preview changes before merging them
git diff
Stash
Creating a stash (think of it as a temporary place, like a clipboard to save changes without marking them deep in history) of changes to allow you to switch branches without committing.