Git Usage

Git Docs

Pro Git:

Visual Git:

Merge vs Rebase:

Subtleties of reverting:

Getting started with Git

Do these steps before doing anything else in git. You need your name and email set correctly so that commits get attributed properly to you.

  git config --global "Your Name"

  git config --global
  git config --global core.editor emacs
  git config --global merge.tool vimdiff

Creating a new, local Git repo

Go to the root of the source tree that you want to put into Git. Type this command:

  git init

This will create a .git directory in the directory you are in. The .git directory will contain all of the Git repository. Don't delete it!

To see the status of your project, type:

  git status

Likely, there will be files listed that you don't want Git to bother with. Create a .gitingore file (which you will check into Git) that lists the files to ignore (wildcards are valid).

Pushing an existing Git repo up to GitHub

Sign in to with your username and password.

Click on the "create new repo" icon (upper right corner of page).

Type in a repository name and, if you want, a description. I used a repository name of: ProjectEuler.

Unselect "Initialize this project with a README".

Click on "create repository".

Switch over to your linux machine that has the repository you want to push. cd to its root directory. Type these commands:

  git remote add ProjectEuler
  git push ProjectEuler master

  Username for '': username
  Password for '':
  Counting objects: 26, done.
  Delta compression using up to 2 threads.
  Compressing objects: 100% (26/26), done.
  Writing objects: 100% (26/26), 10.97 KiB, done.
  Total 26 (delta 10), reused 0 (delta 0)
   * [new branch]      master -> master

When pushing to the remote, you are allowed to select the local name by which you will refer to your local repo. To make it easy on myself, I gave it the same name as the remote repo.


Popular posts from this blog

Patching VMware Tools in Fedora 18

Programming language notes, links

Questions to ask about yourself, your job, your company