From Healthcare Robotics Wiki
Revision as of 18:34, 20 April 2012 by Advaitjain (Talk | contribs) (Clone from the internal server)

Jump to: navigation, search


Tips and Tricks

Customize your bash prompt

Show the branch name

Method 1
  • The following steps allow you to have colored text at the command prompt for telling you which current branch you are using:
    • Download the script from here and put in home directory
    • Add these lines to your .bashrc file:
      • source ~/git-completion.bash
      • export PS1='\[\e[36;1m\]\u@\[\e[32;1m\]\H:\[\e[0m\]\w\[\e[31;1m\]$(__git_ps1 "(\%s)")\[\e[0m\]>'
        • lots of this command is text coloring, see this site for details
    • Git colored command prompt.png - example of what this does
Method 2

Add this to your bashrc:

function parse_git_branch {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
export PS1="[\u@\h \W]$RED\$(parse_git_branch)$COLOR_NONE\$ "

Git prompt advait.png

Git Repositories for Internal Use


  • Advait would like to have internal git repositories as well.
  • The goal would be to use these for active development and release by merging to a repo on gt-ros-pkg hosted on google code.

Create a new git repository on internal server

  1. ssh mycroft@skynet
  2. cd internal_git_bare
  3. mkdir test_repository
  4. cd test_repository
  5. git init
  6. touch .first
    • for some reason git doesn't like completely empty repositories
  7. git add .first
  8. git commit -m "initial dummy commit"
  9. Convert to a bare repository using steps from here:
    1. cd hrl_haptic_manipulation_in_clutter/
    2. git config --bool core.bare true
    3. rm -rf .first
    4. ls -la
      • you should see a .git

Steps on each client machine

Clone from the internal server

  1. cd to whichever directory you want to keep your repo in. (e.g. cd ~/git)
  2. git clone

Cloning a specific branch

  1. git clone -b advaits_branch
    • by doing this, I get only advaits_branch and not the master.

Pushing a branch to the internal git server

  1. git push origin advaits_new_branch

After pushing a branch:

  1. git branch -r
    • confirm that the branch show up as origin/advaits_new_branch
  2. git branch -d advaits_new_branch
    • delete the local branch.
  3. git checkout --track origin/advaits_new_branch
    • Check out and track the new remote branch

Checkout and track a new remote branch

  1. git check out --track origin/advaits_new_branch

Adding a remote branch (from a different repo)

  1. git remote add -f <new_branch_name> <path_to_repo>

To release code

  1. create an appropriately named release branch.
  2. push that release branch to the internal server.
  3. create a new git repository on gt-ros-pkg for the stack to be released.
  4. clone this gt-ros-pkg repository to your computer.
  5. add internal repository as a remote branch on your computer's clone of gt-ros-pkg repo:
    git remote add -f <release_stack_name><release_stack_name>
  6. perform a merge:
    git merge <release_stack_name>/<release_branch>
  7. optionally reset the history:
    git reset --soft HEAD^
  8. git commit -a
    • put in an appropriate release message.

Coverting a stack from svn to a git repository

  1. ssh mycroft@skynet
  2. cd internal_git_bare
  3. get a specific folder from svn and make a git repo out of it:
    git svn clone
  4. Convert to a bare repository using steps from here:
    1. cd hrl_haptic_manipulation_in_clutter/
    2. git config --bool core.bare true
    3. rm -rf *
    4. ls -la
      • you should see a .git

Old stuff

  1. git checkout google_code_master
  2. git checkout internal_hrl <path to files to release>
    • got this command from here and here.
    • this will get the files that we want to release, but the history will not be available in the public repository. It will still be available in the internal repository.
  3. git commit -a
    • type in some descriptive release message.
  4. git checkout internal_hrl
    • switch back to the internal_hrl branch
  5. ssh to skynet and push to google code.

To get changes from google code repository

Merge the changes in the google_code_master branch with the internal_hrl branch

  1. git checkout google_code_master
  2. git pull
  3. git checkout internal_hrl
  4. git merge google_code_master

maybe useful commands?

  1. git checkout --track origin/internal_hrl
    • now you will see two branches (master and internal_hrl)
    • usually Advait would expect people to work in the internal_hrl branch

Create bare git repository on internal git server

  1. ssh -lmycroft
  2. mkdir internal_git_bare
  3. cd internal_git_bare
  4. Clone gt-ros-pkg with advait as the user on
    git clone
  5. Convert to a bare repository using steps from here:
    1. cd gt-ros-pkg.hrl/
    2. git config --bool core.bare true
    3. rm -rf *
    4. ls -la
      • you should see a .git
  6. git branch -m master internal_hrl
    • rename master to internal_hrl

Add a remote branch to work directly with the google code repository

  1. git remote add -f gt-ros-pkg.hrl_google_code
  2. git checkout -b google_code_master gt-ros-pkg.hrl_google_code/master