Migrate a Project#
Many projects that should be accessible for SWW/ENG-members in the future exist already in other locations which will soon be obsolete, such as Renku or Switch Gitlab. Also, you might want to import Eawag-related projects from your private GitHub/GitLab account or from the ETH-GitLab.
Here, we provide a guide on how you can migrate a project to the new Eawag GitLab. It explains which points you have to take care of before the migration and after how to change the remote repository in order to push your project to the new location.
If you have no Eawag GitLab account yet or not yet used git to version your code, please have a look at our guide for Getting Started.
If you are using advanced features of gitlab, such as issues and merge requests, please get in touch with the admins (See ENG and SWW GitLab Documentation). They have some scripts which facilitate the migration process concerning these features.
Before the Migration#
Make sure that…
Everyone working on the source repository is informed and have pushed their changes. They should currently not apply any further changes.
You have an empty target repository (Start a Project in the Right Place). Please tell your admins to create it without a README.
the local and remote repository are up to date (see below)
If you don’t have the source project locally, Clone your Repository
You have a Backup of your project. An easy way to do this is to download the zip-folder via
Code. Make sure to backup also the data which might not be included. Also, check if there are any branches which you want to preserve.You can Connect to GitLab with SSH (the new Eawag GitLab)
We will also mention that this is a great opportunity to clean up your project and only transfer the necessary.
Ensure Everything is Up to Date#
To make sure your local repo and remote repo (e.g., on GitHub, GitLab, Bitbucket) are in sync and up to date, follow these steps:
Navigate to your local git repository
cd C:\Users\username\...\yourproject
Check your current status:
git statusThis shows whether you have uncommitted changes or if your local branch is behind/ahead of the remote. If it says
Your branch is up to date with 'origin/main'and you have only one branch, then both are in sync and you can skip the next steps.Make sure you’re on the right branch:
git checkout main # or whatever branch you’re working on
Pull the latest changes from remote:
git fetch origin # updates your local knowledge of the remote. git pull origin main # brings remote changes into your local branch.
Commit your local changes (if you have any):
git add . git commit -m "Your commit message"
Push your changes to the remote:
git push origin main
Double-check synchronization:
git status
Changing the Remote Repository#
If your local repository is already up to date and you want to change the remote, follow these steps:
Check your current remotes:
git remote -v
Change the remote URL
git@gitlab.eawag.ch:sww/subgroup/myproject.gitwith your own project URL. To find it, navigate onto your target project page, clickCodeand copy the URL underClone with SSH:git remote set-url origin git@gitlab.eawag.ch:sww/subgroup/myproject.git
Push your local branch to the new remote and set upstream tracking:
git push -u origin main
The
-uflag sets the upstream branch, so futuregit pushandgit pullcommands will work without specifying the remote and branch.Archive your old repository (under
Settings–>General–>Advanced). This will turn your old repository into read-only.Share the new link with whom it may concern, ensure that the data used in the project is accessible as well.