git commands

snowpuppy edited this page Mar 25, 2012 · 3 revisions

Table of Contents

Get Changes From Main Repository

Register the main repository as upstream so that you can pull changes from the main repository before delivery.

 git remote add upstream git@github.com:snowpuppy/vga_9s12.git

Pull Changes from the main repository. This adds the changes from the main repository to the one in your terminal. These changes won't be on github yet.

 git fetch upstream
 git merge upstream/master

Put Changes on GitHub

This command syncs the contents of the repository on your local machine with your repository on github. You must submit a pull request to put the changes in the main repository. (I'm going to work on making this more automatic.)

 git push origin

Put Changes on Main GitHub Repository

This command will push your changes to the main repository in snowpuppy's account. Note that you need upstream set up first.

 git push upstream master

Prepare Your Repository For Pushing

List the status of your repository to see any untracked changes that you may want to add. Untracked changes won't be committed ever.

 git status

See a list of all commits that have been done for your repository

 git log

Add files to your repository. Multiple files seperated by spaces will add all of the files and or directories to the repository. Using "." for the filename will add all files in the current directory.

 git add <filename>

Similarly you can get rid of a file with the command below.

 git rm <filename>

Commit all changes that git status says are ready to be committed. Committing means that your changes and new files are officially part of the repository. If you created a new file then it must be added before you commit changes. If you want to remove a file, make sure you used "git rm <filename></filename>" to get rid of it.

 git commit -m "what did I commit/why"