.. _migration: 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 :ref:`quickstart`. If you are using advanced features of gitlab, such as **issues and merge requests**, please get in touch with the admins (See :doc:`index`). 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 (:ref:`start-project`). 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, :ref:`clone-repo` - You have a Backup of your project. An easy way to do this is to download the zip-folder via :code:`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 :ref:`connect_gitlab_ssh_windows` (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: 1. Navigate to your local git repository .. code-block:: cd C:\Users\username\...\yourproject 2. Check your current status: .. code-block:: bash git status This 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. 3. Make sure you’re on the right branch: .. code-block:: bash git checkout main # or whatever branch you’re working on 4. Pull the latest changes from remote: .. code-block:: bash git fetch origin # updates your local knowledge of the remote. git pull origin main # brings remote changes into your local branch. 5. Commit your local changes (if you have any): .. code-block:: bash git add . git commit -m "Your commit message" 6. Push your changes to the remote: .. code-block:: bash git push origin main 7. Double-check synchronization: .. code-block:: bash 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: 1. Check your current remotes: .. code-block:: bash git remote -v 2. Change the remote URL ``git@gitlab.eawag.ch:sww/subgroup/myproject.git`` with your own project URL. To find it, navigate onto your target project page, click ``Code`` and copy the URL under ``Clone with SSH``: .. code-block:: bash git remote set-url origin git@gitlab.eawag.ch:sww/subgroup/myproject.git 4. Push your local branch to the new remote and set upstream tracking: .. code-block:: bash git push -u origin main The ``-u`` flag sets the upstream branch, so future ``git push`` and ``git pull`` commands will work without specifying the remote and branch. 5. Archive your old repository (under ``Settings`` --> ``General`` --> ``Advanced``). This will turn your old repository into read-only. 6. Share the new link with whom it may concern, ensure that the data used in the project is accessible as well.