Skip to content
bmenke92 edited this page Oct 4, 2011 · 3 revisions

Basics of using Git

Creating a repository:

git init
git remote add origin pathToOrigin

git init creates a new repository in the current directory. git remote add origin tells git to add a new remote repository named origin(git push and pull default to origin) from pathToOrigin.

Adding and committing files:

git add .
git commit -am "Useful commit message describing changes here"

git add adds the specified files to the repository. The . tells add to add all new files. git commit tells git to actually save the changes into the repository like svn ci. The -am are arguments to git commit, a means add and remove files if needed, m means message. All commits must have a message.

Branching:

git branch BRANCHNAME

git branch is the basic command for dealing with branches. git branch BRANCHNAME creates a new branch called BRANCHNAME. If left without arguments it displays a list of branches.

git checkout BRANCHNAME

git checkout BRANCHNAME moves you into BRANCHNAME

git merge BRANCHNAME

git merge pulls the changes from BRANCHNAME into the current branch.

GitHub repository:

git pull origin GithubBranchName

Pulls the changes from the specified branch on github into the current branch. Git knows how to merge two files fairly well so changes to your local files will not be lost.

git merge origin/GithubBranchName

Same as above.

git push GithubBranchName

Sends your changes to the github branch creating it if it doesn't exist.

Clone this wiki locally