Wednesday, May 2, 2012

Git copy repository

Let's say I had test codes in separate repository (e.g.

I wanted to get rid of test repo and move its stuffs to main project_x repository (let's say it is And of course we want to keep the history of test project.

Quick notes on two git concepts required:

  • git remote:
    try "git remote -v", you will see a list of remote repository locations, with alias 'origin'. Git automatically created origin alias when you cloned. 
  • git pull <a> <b>
    It 'fetch'es the changes in <a> and will merge those to <b>
Now here is how all the 'copy'ing is done:

#go to the projec_x repo
#add the 'test' alias
git remote add test

# Test if now there is 'test' alias
git remote -v 

# Pull all the changes in test and merge to master
git pull test master

# We no longer need the alias
git remote rm test

# Push
git push

No comments:

Post a Comment