-->

Friday, July 26, 2013

Manage a fork of git repository - Redmine


Manage a fork of git repository - Redmine

Using redmine I want to maintain my own custom redmine , and still be able to update with latest changes from newer version.
I have forked the redmine repo , and created 2 local branches:
my_work - dvelopment branch with my changes
my_deploy - the version that is on production

We already have set-up the remote branches and we can see them using :

>git remote -v

origin git@github.com:haimlankry/redmine-1.git (fetch)
origin git@github.com:haimlankry/redmine-1.git (push)
upstream git://github.com/redmine/redmine.git (fetch)
upstream git://github.com/redmine/redmine.git (push)

The "origin" is my fork of the original git, located on the "upstream" remote.

first we will update from upstream to get the latest updates:

>git fetch upstream 

Re-basing 

We had before 2 branches, my_work and my_deploy, in my_work, we have some changes relative to an old version in the upstream (2.2-stable), we will take only our changes and rebase them on a newer version.
we should be in the my_work branch .
we can check before rebasing to see our changes only using:

>git log upstream/2.3-stable..HEAD
we should see only our changes listed

Then we do the rebase:
>git rebase upstream/2.3-stable

Now our my_work branch , has the new version (2.3-stable) and our changes applied as the last commits.

Deploy

We will override the my_deploy branch with the my_work version.
We first move to the my_deploy branch

>git co my_deploy 
Switched to branch 'my_deploy'
>git reset --hard my_work


Now we have the my_deploy branch with the latest version.
now we should updated the origin remote branch, with both branches changes.
we have to force push cause we changed the commit history.
>git push origin -f
...

To git@github.com:haimlankry/redmine-1.git
 + 60d222b...2ea745b my_deploy -> my_deploy (forced update)
 + 7ccf04b...2ea745b my_work -> my_work (forced update)
...

last step is to update the version on the remote server by pulling

production server

we should be in the my_deploy branch (only one on production)

stop the web server (sudo service apache2 stop)
git fetch origin my_deploy
git reset origin/my_deploy --hard
start the apache http



No comments:

Post a Comment