Private Git repo - on cloud
Every developer has some space on cloud. Be it Dropbox, Google Drive, One Drive, iCloud, or anything.
This space is also exposed as a folder on our Windows or Mac.
So lets utilize this space as a Git repo - on cloud.
Prerequisites
- space on cloud (Dropbox, GoogleDrive, OneDrive, iCloud or any)
- drive mounted on Windows or Mac as a folder
On my MacBook pro, I have my Dropbox mounted on ~/Dropbox.
Create a folder of your choice on your drive. You do not want git related files spread out in your drive right?
I have ~/Dropbox/git/
Creating a Git Repo
cd ~/Docker/git
git init --bare winner.git
This creates a new folder ~/Docker/git/winner.git with git related files inside this new folder.
Checkout project from repo
cd ~/my_projects
git clone ~/Dropbox/git/winner.git
This will checkout "winner" project from our git repo.
How is this on cloud?
Wherever you have your cloud drive access, your git repo is with you. And it is automatically synched by your cloud provider.
Yes, this is not as good as having a "github" account. But it allows you to
- have a private repo at no cost
- share your drive folder with your friends
If you want a complete git-lab experience, you can try Gitlab CI-CD on Docker.
Existing project without git?
You might have an existing project, and you would want to connect it to your newly created repo.
cd ~/study/testgit initgit add .git commit -m "Initial commit"git remote add origin ~/Dropbox/git/winner.gitgit push origin master
git init
It initializes a new git repo in current folder. We can use it without connecting it to an external git repo. So it acts as an in-place git repo.
git remote add origin <git-uri>
This is the one that does the trick - it connects present working directory git to the git repo hosted on a folder / github. In our case, we connected it to ~/Dropbox/git/winner.git folder.
Comments
Post a Comment