Using git on Linux 03.08.2018

Alright

To begin, it's a good idea to set your username and email globally.

$ git config --global user.name "Fname Lname"
$ git config --global user.email "me@me.com"

If you are working with a repo where you have a different username and/or email you can cd into the project directory and run the same commands without the --global tag. This will apply the new username and email only to the current project.

New project

assumes empty repo exists

$ git init
$ git remote add origin git@bitbucket.org:user/repo.git

Clone an existing project

$ git clone git@bitbucket.org:user/repo.git

After making local changes...

// add a single file
$ git add filename.js
// add all changed files
$ git add -A
// commit changes
$ git commit -m "Describe changes"
// after one or more commits
$ git push -u origin master

Branching

$ git checkout -b my_branch
// After making changes...add, commit and push to new branch
$ git add -A
$ git commit -m "branch changes"
$ git push -u origin my_branch
// list all branches
$ git branch --list
// switch back to master branch
$ git checkout master
// optionally see changes between 2 branches
$ git diff master my_branch
// merge new branch into master
$ git merge my_branch
// once branch is merged we don't need it anymore
$ git branch -d my_branch