txusko
1/8/2014 - 8:17 PM

Git / Github utils

Git / Github utils

#Create the repository in github -> https://github.com/new
#We supose "first_app" as the repository name

#Push up the aplication
$ git remote add origin https://github.com/<username>/first_app.git
$ git push -u origin master

## BRANCHES

#Create a branch
$ git checkout -b modify-README

#List local branches (* branch we're currently on)
$ git branch

#Change something
$ nano -w README.rd

#Commit the changes
$ git commit -a -m "Improve the README file"

#Change to master branck
$ git checkout master

#Merge branch to master
$ git merge modify-README

#Delete branch
$ git branch -d modify-README

#Push to github
$ git push


# For illustration only; don't do this unless you mess up a branch
$ git checkout -b topic-branch
$ <really mess up the branch>
$ git add -A
$ git commit -a -m "Make major mistake"
$ git checkout master
# the -D flag will delete the branch even though we haven’t merged in the changes.
$ git branch -D topic-branch 
#Configuration
$ git config --global user.name "Your Name"
$ git config --global user.email your.email@example.com
#config: Aliash checkout == co
$ git config --global alias.co checkout
#config: Editor
$ git config --global core.editor "subl -w" #"mate -w" for TextMate, "gvim -f" for gVim, or "mvim -f" for MacVim.

#First time repository setup
$ git init

#Edit .gitignore for exclude files and directories
$ nano -w .gitignore

#First Add
git add . #add
git add -A #add all

#Status
$ git status

#First commit
$ git commit -m "Initialize repository"

#List of commits
$ git log

#undo changes (ex: when you delete something)
$ git checkout -f