Migrate your Git repositories to Gitea

Exodus

Classic Migration

Most moves involving Git repos are likely to differ significantly from my special case. You will usually need to move from SERVER_1 to SERVER_2. You can see the specific steps in Listing 1.

Listing 1

Classic Migration

git clone <ORIGIN-URL> <LOCAL_REPO>
cd >LOCAL_REPO>
git branch -a
for current_branch in $(git branch -a | grep -o -E '(remote.*)' | grep -v ' -> ' | cut -f3 -d'/') ; do
  git checkout "${current_branch}";
  git pull;
done
git fetch --tags
git remote rm origin
git remote add origin <NEW_ORIGIN_URL>
git push origin --all
git push --tags

The first line clones the repository from the previous server to <LOCAL_REPO> and is followed by a change to the directory of the new <LOCAL_REPO> working copy. The git branch -a lists all branches and checks them out. The fetch ensures that all the tags in the repository exist in the working copy.

With the tags, all the data from the remote repository are now on the local system. The command

git remote rm origin

cuts the connection to the previous server to receive the URL of the new server as the origin in the next git remote line. Finally, the content and tags are pushed to their new home in the last two lines.

Conclusions

With very little risk and manageable overhead, you can get rid of potentially outmoded software within a few hours. Although Gogs might live on and regain momentum again at some point, I don't want to rely on that possibility. I consider it important not to leave something as fundamental as version control to chance. During this move, I realized once again how sophisticated and powerful Git really is. It almost seems as if Linus Torvalds anticipated all the use cases during development.

The Author

Thomas Reuß is a passionate Linux admin who is hugely interested in security. He is currently working as a consultant in the SAP environment.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs



Support Our Work

ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.

Learn More”>
	</a>

<hr>		    
			</div>
		    		</div>

		<div class=