An incomplete just-in-time cheatsheet for git. Things are added as required.
To add an existing repo to a remote repo
-
For github/bitbucket, create repo there first, and get git address, eg
git@bitbucket.org:taktran/[some project].git
-
Set up remote branch
git remote add origin git@bitbucket.org:taktran/[some project].git
-
Push to origin
git push origin master
-
To configure master to track the remote branch
git config branch.master.remote origin git config branch.master.merge refs/heads/master
-
Now you can just do
git push
Throwing away a dirty merge
git reset --hard HEAD
Throwing away a committed merge
git reset --hard ORIG_HEAD
Squash a commit, go into the branch you want to merge to eg, for merging feature
branch to master
, git checkout master
, then:
# Note that the message does not get used if there are no conflicts.
git merge --squash -m "Some msg" feature
-
Create remote branch
git push origin HEAD:refs/heads/[new_branch] git fetch origin # Update everything git branch -r # Lists all remote branches
-
Start tracking new branch
git checkout --track -b [new_branch] origin/[new_branch]
-
Update everything with
git pull
To delete a remote branch
git push origin :new_branch # Deletes the remote branch
git branch -d new_branch # Deletes the local branch
Can diff between different tags. --
represents current
git diff 0.5.1 -- models/*
-
Create app
heroku create --stack cedar
-
Deploy code
git push heroku master
-
Rename app
heroku rename [new name]
Or to add heroku to an existing folder:
git remote add heroku git@heroku.com:[project name].git
For multiple deployment locations, use --app [project name]
flag to run commands
heroku ps # Check processes
heroku logs
heroku run console
heroku run rake -T
heroku run rake db:migrate