Friday, March 20, 2015

Commands

Commands

Create and switch to a new branch 

git checkout -b [name_of_your_new_branch]

delete a local branch in git

git branch -d [name of the branch]

create a new branch and track it with a remote branch

git checkout -b [name of new branch] -t [origin/<name of remote branch>]

delete last commit 

git reset --soft HEAD~1

renaming a branch

git branch -m <oldname> <newname>

renaming current branch

git branch -m <new name>

see code changes in last two commit

git log -p -2

Cloning a git repository (after setting up ssh key pair)

git clone git@github.com:<userID>/<repository>.git

git clone git@github.com:coderetriever/Android.git

Creating a new repository on the command line

echo "# HTML5" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:coderetriever/HTML5.git
git push -u origin master

Push an existing repository from the command line

git remote add origin git@github.com:coderetriever/HTML5.git
git push -u origin master


Saturday, March 14, 2015

SSH Key Pairs

SSH keys are a way to identify trusted computers, without involving passwords.

Generate private and public key pair.

Generating SSH keys 

1. ls -la ~/.ssh/git
2. ssh-keygen -t -rsa -C "<emailID@email.com>"
      Enter location of id_rsa file
      Enter passphrase

Add key to SSH agent

1. Ensure SSH agent is enabled 
      eval "$(ssh-agent -s)"
2. Add private key to SSH agent
      ssh-add ~/.ssh/git/id_rsa

Add public key to git account

1. pbcopy < ~/.ssh/git/id_rsa.pub

Test the connection

1. ssh -T git@github.com

Cloning a repository

/home:>git clone git@github.com:coderetriever/Android.git

creates /home/Android directory with all the source folders

Wednesday, November 12, 2014

Distributed Git

Git on the Server

Git Branching

Git Basics