My Github account is perhaps the most important internet account I "own". Besides being the #1 companion to my resume, it stores crucial code that I have built over the last few years for my side projects. Long story short, this is an account I can't afford to loose.
Well...I can afford to loose it, what I can't afford to loose is the code that is stored inside. I'm a strong proponent of not putting all your eggs in one basket so I backup my most important code to Gitlab.
Gitlab I am using as an example here, as you can do this using any git repository from any git provider, and the process is very simple.
Create an account + code repository: The first step is to create a GitLab account and a code repository to keep a backup of your code. I won't go into too much detail here, you guys know how to create git repo.
Grab the remote URL and add it to your repo: When you setup a repo, you will often use the command
git remote add origin <git_url>
This will add the origin URL to your repo and assign it to the name "origin". From here you can push to "origin".
We will use this same command but we will change a few things, now instead of adding an 'origin', add a 'backup' instead like:
git remote add backup <git_url>
(it should be noted here that the name like 'origin' or 'backup' does not matter, you can pick whichever name you want)
Push to your new remote: After adding the new remote url, you can now push to it using:
git push -u backup master
Here, "backup" is the name you set in the last step and "master" is the branch name.
That's it! Your code is not backed up to another Git repository.
Top comments (2)
Thanks, I’ll give it a shot!
Quite helpful. Thanks!