Historical project documentation. Content is maintained in GitLab.

GITCheatbook

Development/UsingSVN/UsingGIT/GITCheatbookNext Chapter

Using GIT for UAVP-NG - GIT Cheatbook

A cookbook of useful GIT commands.

Cloning and creating a topic branch to work on

Clone and work on UAVP-NG Sources

  git clone git+ssh://git@dev.uavp.ch/uavp-ng/master/sources
  cd sources
  git remote add <your-username> git+ssh://git@dev.uavp.ch/uavp-ng/dev/<your-username>
  git checkout -b sources-<topic-branch-name>  

Clone and work on UAVP-NG Master Hardware

  git clone git+ssh://git@dev.uavp.ch/uavp-ng/master/hardware
  cd hardware
  git remote add hardware git+ssh://git@dev.uavp.ch/uavp-ng/merge/hardware
  git checkout -b hardware-<topic-branch-name>

Pushing topic branch to public repository

Push Sources topic branch to public developer repository for merge

  cd sources
  git push <your-username> sources-<topic-branch-name>:merge-sources-<topic-branch-name>

Push Hardware topic branch to hardware merge repository for merge

  cd hardware
  git push hardware hardware-<topic-branch-name>:merge-hardware-<topic-branch-name>

Checking out remote branches of a public developer repository

  git remote add <dev-username> git+ssh://git@dev.uavp.ch/uavp-ng/dev/<dev-username>
  git ls-remote <dev-username>

Fetching a remote branch from a public developer repository and check it out as a local branch

  cd sources
  git remote add <dev-username> git+ssh://git@dev.uavp.ch/uavp-ng/dev/<dev-username>
  git ls-remote <dev-username>
  git fetch <dev-username> sources-<topic-branch-name>
  git checkout -b <dev-username>/sources-<topic-branch-name>

Removing a local branch

  cd sources
  git branch -d <topi-branch-name>

Removing a remote branch

Removing a remote branch in your public developer repository

  cd sources
  git push --delete <your-username> sources-<topic-branch-name>

Removing a remote branch in the Hardware merge repository

  cd hardware
  git push --delete hardware hardware-<topic-branch-name>

Resetting working copy

  git reset --hard HEAD

/!\ This will remove all your local changes and reset your working copy back to the state of the last commit!

Resetting a changed file in the working copy

  git checkout -- <file-path>

/!\ This will remove all your changes in that file!

Resetting a changed file in the staging area

  git reset -- <file-path>

Loosing last commit

  git reset --hard HEAD^

/!\ This will remove all your local changes and reset your working copy back to the state before the last commit. The last commit will be lost. The changes in that commit will be lost.

Creating remotes for all public developer repositories

  cd sources
  for d in amir axel benjamin christi florian marco martin mattes matze mbuhr peter ralf stefan stefanrado tim volker; do git remote add $d git+ssh://git@dev.uavp.ch/uavp-ng/dev/$d; done

Create a patch file of changes in a GIT branch

  git checkout <your-branch>
  git format-patch master --stdout > patch-file.patch

Apply a patch to a new branch in a GIT repository

  git checkout -t -b <new-branch>
  git apply --stat patch-file.patch
  git apply --check patch-file.patch
  git am --signoff < patch-file.patch