Copy GitLab main branch code to GitHub DEV branch || replace GitLab main branch with GitHub DEV branch



 Step:1 Clone GitLab Repository

  • If you haven't already, clone your GitLab repository to your local machine.
            git clone <GitLab_Repository_URL>

Step:2 Add GitHub Repository as a Remote

  • Add the GitHub repository as a remote to your local GitLab repository.
            git remote add github <GitHub_Repository_URL>

Step:3 Fetch the GitHub DEV Branch

  • Fetch the main branch from the GitHub repository.
            git fetch github DEV

Step:4  Reset GitLab Main Branch

  • Reset the GitLab main branch to match the GitHub DEV branch.
  • Checkout to main if you are currently not in main branch in your locally,then run below command
            git reset --hard github/DEV

Step:5 Force Push to GitLab

  • Force-push the updated main branch to the GitLab repository.
  • Warning: Be cautious with force-push, as it overwrites the branch on the remote repository. Make sure you have backups and that no one else is working on the same branch.
            git push -f origin main





If you have any doubt ,any question you can ask me......!




Comments

Popular posts from this blog

Step-by-Step Tutorial: How to Backup and Restore MongoDB Databases 2023