Git

Git requires SSH key pair authentication to access remote repositories.

Generate a 2048-bit RSA Encrypted SSH key pair.

ssh-keygen -t rsa -b 2048

Generate a 4096-bit RSA Encrypted SSH key pair.

ssh-keygen -t rsa -b 4096

This should generate a file named id_rsa.pub in your /home/username/.ssh folder. You must copy this key and enter it into your user account for repository hosting services.

Display your Public Key.

cat ~/.ssh/id_rsa.pub

Sites such as Github, Unfuddle, and BitComet require your SSH Public Key to access their repositories. One you have added the key to your account you are ready to commit and clone repositories.

Check your current git identity.

git config -l

Identify yourself to git.

git config --global user.name "Your Name"
git config --global user.email user@example.com

Example:

git config --global user.name "John Doe"
git config --global user.email john.doe@example.com
It is best to use your real name and your email address. That way people know commits are coming from you.

Initialize and create a new git repository.

git init

Add all files and folders to the local git repository.

git add *

Add a single file to your local git repository.

git add filename

Example:

git add readme.txt

Commit your changes to your local git repository.

git commit -m "explain your commit here."

Example:

git commit -m "initial commit"

Add a remote repository to your git repository.

git remote add remote-name git://example.com/username/repository-name.git

Example:

git remote add origin git://github.com/sk33lz/zenlike.git

Configure a branch on your remote repository as an upstream server.

git config remote.remote-name.push refs/heads/branch-name:refs/heads/branch-name

Example:

git config remote.origin.push refs/heads/master:refs/heads/master

Push your changes to your remote git repository.

git push -u remote-name branch-name

Example:

git push -u origin master

Clone a Git repository. (Read / Write)

git clone git@example.com:username/repository-name.git

Example:

git clone git@github.com:sk33lz/zenlike.git

Clone a Git repository . (Read Only)

git clone git://example.com:username/repository-name.git

Example:

git clone git://github.com/sk33lz/zenlike.git
Next