Initialize a new git repository:
in target folder execute:git init
How to add a local ssh key to GitHub:
generate ssh key on Linux VM:ssh-keygen
copy the public key from target folder, by default /home/username/.id_rsa.pubcat /home/username/.id_rsa.pub
paste key to GitHub:
user settings —> SSH and GPG keys —> New ssh key
Add remote repository:git remote add origin git@github.com:username/repository_name.git
Check on what branch you are:git branch
Check what local and remote branches git knows about:git branch -a
Switch to the existing branch:git checkout "existing-branch-name"
Create a new branch:git checkout -b "new-branch-name"
Push the new branch to remote:git push -u origin "new-branch-name"
Create an existing branch and move HEAD there:git checkout -b "new-branch-name" "existing-branch-name"
Fetch all info about remote branches:git fetch --all
Diff one branch against another:git diff master..staging
Rename git branch:git branch -m "existing-branch-name" "new-branch-name"
Help and man:git help branch
git branch --help
man git-branch
Delete a branch:git branch -d "branch-name-to-delete"
Forcefully delete a branch (think twice before using it):git branch -d --force "branch-name-to-delete"
Full new feature flow:
# Start a new featuregit checkout -b new-feature master
# Edit some filesgit add <file>
git commit -m "Start a feature"
# Edit some filesgit add <file>
git commit -m "Finish a feature"
# Merge in the new-feature branchgit checkout master
git merge new-feature
git branch -d new-feature