Saturday, July 15, 2017

Creating a GIT repository on a network drive

Use GIT to keep my source on anetwork drive

But if the source is on my PC only, it loses some of the main ideia [to keep my source code safe].
I could use github or something like that... But then it becomes open source...

Also, if I use a diferent machine, i want to use the same reposotory...

So...
Wit Linux, UBUNTU... How to do it?

The idea is to create a shared folder that maps to a network drive. And use that has the shared repository...
Then use git to pull / push from it!|

Mount network Drive

- Choose where you want [I am going to put it under "/home"
- Create the folder where you want to map it
      sudo mkdir /home/shared-git
- Mount the network drive
      sudo gedit /etc/fstab
 * add line
      //192.168.1.1/a/shared-git /home/shared-git cifs guest,uid=1000,iocharset=utf8 0 0
- Execute to re-mount drive
      sudo mount -a

Now i have a path mapped to the network!


Create a net repository on the shared path

- Create the repository
      cd /home/shared-git
      git init --bare
Push the repository to new location
      cd /[project path]
      git remote add origin /home/shared-git
      git push origin master
Now we have the repository updated !

Push the repository to new location

      cd /[project path]
      sudo git push -u origin master


To clone it on a diferente machine [with the same share folder]

      git clone /home/shared-git/ [folder]


To sync the local repository from shared folder

Fetch project
      git fetch origin
Clean current projecto
      git clean  -d  -fx ""
Get changes
      git pull

DONE !

Enviroment:

Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial

Problems:

I had problems instaling
      sudo apt-get install cifs-utils

Errors were encountered while processing:
libmirprotobuf3:amd64
libmirclient9:amd64


Steps to fix it:
      sudo apt-get install --reinstall libmirprotobuf3
      sudo apt autoremove
      sudo apt-get update