Wiki

Clone wiki

scl-manips-v2 / install / git_pointers

Short introduction to git

In general, you can find a good documentation on the use of git on this website:

How to do submodules

adding a submodule to git

$ git submodule add git@bitbucket.org:tkroeger/lwr.git 3rdparty/lwr
$ git status
$ git commit -m 'first commit with submodule lwr'
$ git log -1
$ cd 3rdparty/lwr/
$ git log -1

Cloning a Project with Submodules

$ git clone git://github.com/schacon/myproject.git
$ git submodule init
$ git submodule update 

This is the case because the pointer you have for the submodule isn’t what is actually in the submodule directory. To fix this, you must run git submodule update again:

$ git submodule update

You have to do this every time you pull down a submodule change in the main project. It’s strange, but it works.

TODO: make this more complete....

Getting started

Navigate to your git repository:

cd scl-manips-group/

The status command shows you on which branch you are currently on. It also shows you, what changes have not been staged or tracked yet:

git status

Now run

git pull

to update your repository from the remote source.

To see the branching structure:

git branch -a

Create a new branch:

git branch <your name>

To activate the branch:

git checkout <your name>

To upload branch to bitbucket:

git push origin <your name>

Create a new temporary working branch:

git branch <your name>-workspace
git checkout <your name>-workspace

Delete local branch (to setup a tracking branch):

git branch -D <your name>

Checkout remote branch again with tracking:

git checkout --track -b <your name> origin/<your name>

If you are on the 'master' branch, start a new, personal branch to work on:

git branch <your-name>

for example my branch is called

git branch robert

With this command you push your files to your new branch:

git push origin robert

The branch command should show you now, that you have generated a new branch:

git branch

but you have not checked it out, since there is no star next to it, so you need to do so in order to work on the new branch:

git checkout robert
git branch -a
cat .git/config

ls

git checkout master

git branch -D robert

git branch --track robert origin/robert

git branch -a

git checkout robert

git branch -a

Important git commands

A few short explanations to the important git commands, each one has to be added to the basic command git ...:

Getting or Starting Projects

clone: Getting a Project, you do this when you want clone an external repository to your disk. init:

Basic Snapshotting

add:adds file contents to the staging area - necessary before being able to commit them. status: check the status of your repository diff: check what commit: reset: rm: mv:

Branching and Merging

branch: checkout: merge: log: tag:

Sharing and Updating Projects

fetch: pull: push: remote:

Inspection and Comparison

log diff

Customize git color outlook

Customize the git appearance for a better overview.

First have a look how the git diff command appears without modifications:

cd ~/Documents/scl-manips-group
git diff

Apply the color customizations according to the guide on this website:

git config --global color.diff auto
git config --global color.branch auto
git config --global color.interactive auto
git config --global color.status auto

Updated