Archive for the ‘Git’ Category

Git frequently used

Tuesday, February 24th, 2015

// reset local branch to origin’s state

git checkout {branch}

git reset –hard origin/{branch}

 

// checkout new branch from origin

git checkout –track origin/{branch}

 

// merge

git merge {{branch}}

 

// stash when you need to keep changes but aren’t ready to commit them, say to switch branches or pull new work from team members into your unfinished state

git stash

git stash list

git stash apply {stashName}

 

// get git remote url

git config –get remote.origin.url
or
git remote show origin


// create a local branch and switch to it

git checkout -b {name the new branch}

 

// invalidate user so to force password reset

git config –global credential.helper store

 

// remove already added files/folder from git and add to ignore 

git rm -r –cached file-path

 

// did hard reset, clean, need it back!? It hasn’t been garbage collected yet, pfew

$ git reflog
1a75c1d… HEAD@{0}: reset –hard HEAD^: updating HEAD
f6e5064… HEAD@{1}: commit: added file2

$ git reset –hard f6e5064
HEAD is now at f6e5064… added file2

 

// commit everything including untracked

git commit -A

 

// delete folder from repo

git rm -r folder-name

 

// output all branches

git branch -a

 

// delete local branch

git branch branch-name -D

 

// delete remote branch, just add -r for remote flag

git branch -dr branch-name

Rails Git Heroku Terminal command notes

Wednesday, January 19th, 2011

first cd to the project directory:

git init

git add .

git commit master

heroku create “NewApplicationName”

git push heroku master

heroku rake db:schema:load

rake db:schema:dump (handy to dump local db if you’ve been modifying it w/o migrations…)

heroku rake db:migrate