Skip to content

Tutorial: Random, maybe useful git stuff

mcho588 edited this page Aug 28, 2015 · 2 revisions

images/example.png

You should have all cloned your repo following Harvey's ROS setup tutorial

These are some simple git commands you'll probably need to use:

Simple git commands

git commit -m '<meaningful-message>': You should know what this is...

git pull: Pulls the remote server's (so this github) branch into your local branch if your local branch is behind in commits

git push: Pushes the local branch into the remote server's branch if your local branch is ahead in commits

git status: Allows you to check what new files and modified files exist on your current branch

git add <file-name>: This is adding a new/modified file to the next commit

git stash: If you do have any uncommitted changes you don't want to commit yet, but git is prompting you to commit before doing whatever action you're trying to do, use this. It stashes away the uncommitted changes into a temporary storage

git stash apply: Use this to apply the uncommitted changes back into your branch

git branch: See all of the local branches you have, and which one you're on at the moment

git checkout <branch-name>: Change the branch you're on into

git checkout -b <branch-name>: Make a new local branch, and then move into it.

git push origin HEAD: This will make a new remote branch (if there isn't one) of the local branch you're on

git merge <branch-name>: Merges branch with your current local branch

Useful Tips

  • Never work on the master branch, and never push to master branch please :), always make a pull request
  • Checkout -b from master branch when making new branches
  • Always have a local master branch, pull remote, then checkout to the branch you're working on, and merge master branch. This is so that you keep up to date with what's going to be in our "final" version and resolved conflicts early.
  • Commit small changes so it looks like you did something