Migrate manually your fedorahosted git repository to Pagure

I see Pagure has been progressed a lot and is in a very good state that one should use it for their own project hosting.  I was in need to update my project on fedorahosted and realized why not start using Pagure now. I decided to move my projects there. I was knowing how to move source repositories by adding remote repository. I created empty repository on Pagure and then pulled remote source repository into it. I just did that but realized it did not bring all branches and tags. I then got help from Vivek and Farhaan and with the help of them manually migrated to Pagure.

Let me provide here steps to migrate a project say xyz on fedorahosted to pagure. Let’s assume you have your git repo at https://git.fedorahosted.org/git/xyz.git

checkout locally this fedorahosted repository as

git clone ssh://<FASID>@git.fedorahosted.org/git/xyz.git

Check the branches status

$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/feature1
remotes/origin/feature2

Checkout remote branches locally if you have any. You need to ensure all remote branches are locally available. We found how to do this from this stackoverflow question page

$ git branch -r | grep -v ‘\->’ | while read remote; do git branch –track “${remote#origin/}” “$remote”; done
fatal: A branch named ‘master’ already exists.
Branch feature1 set up to track remote branch feature1 from origin.
Branch feature2 set up to track remote branch feature2 from origin.

Then just fetch branch information

$ git fetch –all
Fetching origin

Now, create a new project with same name on Pagure by filling this form.

Suppose you created your project as https://pagure.io/xyz

Now as we have got all the branches locally, next we  add this pagure git repository as remote to fedorahosted xyz project

$ git remote add upstream ssh://git@pagure.io/xyz.git

Then we push all the local branches to remote pagure’s xyz project

$ git push –all upstream
Total 0 (delta 0), reused 0 (delta 0)
To ssh://git@pagure.io/xyz.git
* [new branch]      feature1 -> feature1
* [new branch]      feature2 -> feature2

but above command only pushed all the local branches including master but not any tagged sources. To do that execute following

$ git push upstream –tags
Counting objects: 24, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (24/24), done.
Writing objects: 100% (24/24), 3.75 KiB | 0 bytes/s, done.
Total 24 (delta 9), reused 15 (delta 0)
To ssh://git@pagure.io/xyz.git
* [new tag]         1.4.1 -> 1.4.1
* [new tag]         2.0.0 -> 2.0.0
* [new tag]         2.1.0 -> 2.1.0
* [new tag]         2.2.0 -> 2.2.0
* [new tag]         2.3.0 -> 2.3.0
* [new tag]         2.4.0 -> 2.4.0
* [new tag]         2.4.1 -> 2.4.1
* [new tag]         2.4.2 -> 2.4.2
* [new tag]         3.0.0 -> 3.0.0
* [new tag]         3.1.0 -> 3.1.0
* [new tag]         3.2.0 -> 3.2.0
* [new tag]         3.3.0 -> 3.3.0

Above all steps will migrate your fedorahosted project git source repository including all remote branches and tagged sources to pagure.