Git reference

August 2017 · 1 minute read

Create

Create a new branch

$ git checkout -b {new_branch_name}

Commit

Add changes to staging

$ git status

$ git add —all


Commit changes

$ git commit -m ‘users can be added and removed from projects’

OR

$ git commit -am “Refs  #{ticket_number}  #{message}.”


Push changes to remote origin

$ git push origin {branch_name}

Check and pull changes down from master if these are available

Rebase

Rebase to master and squish commits

$ git rebase -i master

Vim Interactive reference:
	insert changes: i,
	write & quit: :wq
		
  If using a ticketing system, add a reference to the ticket:
	Refs #{ticket_number}

Switch to master branch

$ git checkout master

Rebase branch onto master

$ git rebase {branch_name}

Push to origin/master

$ git push


Delete

Delete local branch

$ git branch -D {branch_name}

Delete remote branch

$ git push origin –delete {branch_name}


Deploy

Deploy from master branch

If you’re using capistrano for deployment and it is configured correctly, you can simply run:

$ cap production deploy