How to use git 1. when starting a new project type git init which intitiates the git repository 2. to add a file git add $FILENAME 3. to check on the status type git status which should list all the files tracking and changes made since last commit 4. to commit your changes type git commit -m "a message goes here" which commits your changes to the repository 5. to connect with github do the following git remote add origin $URL which adds the remote origin to be the URL (case sensitive) 6. to commit those changes to github git push origin master which pushes the changes to the origin (the github repository) master branch How to use the same code over multiple machiens 1. go to the development directory and type git init 2. to clone the code type git clone https://www.github.com/$USERNAME/$project.git (get this from the github page and click Fork) 3. this cloned repo has a default remote named "origin" which points to your fork not the master, change this name git remote add upstream https://www.github.com/$PROJECT_REP/$project_name.git 4. update our files git fetch upstream which pulls new files but doesn't update ours 5. now suppose we go and update code and commit the changes git commit -m "blah" git push origin master this pushes the changes to the master branch 6. now we go to another dev environment and want to work on the code, we update our files with git fetch and now git merge upstream/master this merges your files with the master branch BRANCHING AND STASHING git branch lists all the branches you have available git checkout $BRANCHNAME changes from current branch to branch name NOTE if you haven't committed on current branch, you will need to stash git stash git stash list (lists all the stashes) pops the current stash off the stack (latest stash and deletes it) git stash pop ######################################### # GIT REMOTE # https://git-scm.com/docs/git-remote ######################################### git remote deals with managing remote urls in git. This is useful for interacting with sites like bitbucket and github. > git remote add [remote-name] $URL adds a remote repository with the name remote-name at $URL. Other options exist to specify master, tagging, etc... see docs for details > git remote rename renames a remote with to . Straight forward > git remote set-url [remote-name] $URL changes the remote url of [remote-name]. By default this is often origin. Use to switch from ssh to https > git remote [-v] show [remote-name] displays information about the remotes set-up. -v is useful since it shows the actual remote urls OTHER : to change the name of repository, go to the admin tab on the project homepage. Note you must update remote urls yourself! FROM VIM WEBSITE Create a new repository on the command line touch README.md git init git add README.md git commit -m "first commit" git remote add origin https://github.com/lbovard/3d-boussinesq.git git push -u origin master Push an existing repository from the command line git remote add origin https://github.com/lbovard/3d-boussinesq.git git push -u origin master REmove all deleted files git rm $(git ls-files --deleted)