Last active
          November 8, 2021 13:55 
        
      - 
      
- 
        Save emha69/1332672a37038ffd40f719c41ea79050 to your computer and use it in GitHub Desktop. 
    Local Git Server setup in 10 steps with Ubuntu server and Windows clients
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Step 1. Setup Ubuntu 20.04 Linux server | |
| Step 2. Install software on Windows client(s) | |
| Step 3. Create SSH keys on the clients and copy to server | |
| Step 4. Create remote repository | |
| Step 5. Tweak Git to use SSH | |
| Step 6. Create local repository | |
| Step 7. Push it to the remote | |
| Step 8. Clone to the clients | |
| Step 9. Setup GitHub Desktop client | |
| Step 10. Test it | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Step 1. Basic setup Ubuntu 20.04 server
1. First check if Git is installed
git --version2. If not, install Git with
sudo apt-get updatesudo apt-get install git3. Add git user
adduser git4. Change to git user and create folders
cd /home/gitmkdir ~/.sshchmod 700 ~/.sshtouch ~/.ssh/authorized_keyschmod 600 ~/.ssh/authorized_keysCreate additional
tempfolder, which will be used later for file upload.Step 2. Install software on windows
https://github.com/git-for-windows/git/releases/
For now install with default options.
Step 3. Generate SSH keys on Windows 10
Press Win+R and open CMD for the current user
Generate private and public SSH keys
ssh-keygenSave the
id_rsain .ssh folder under current user's home directory e.g.C:\users\$user\.sshEnter password to protect the private key.
The
id_rsaandid_rsa.pubkeys will be created in theC:\users\$user\.sshfolderCopy the
id_rsa.pubfile to the serverscp id_rsa.pub git@<host>:/home/git/temp/<user>.pubLog in as git user to the server and add the key to the authorized keys
ssh git@<host>cd tempcat <user>.pub >> ../.ssh/authorized_keysLogout from server and try to log in directly, using:
ssh gitStep 4. Create and init remote repository
ssh git@<host>mkdir projects.gitcd projects.gitgit init --barecd ..chown -R git.git projects.gitStep 5. Tweak git on windows to use Windows SSH
Open Git bash console and enter:
git config --global core.sshcommand "C:/Windows/System32/OpenSSH/ssh.exe -i C:/users/$user/.ssh/id_rsaStep 6. Create local repository on Windows PC
c:\Works\projectIf this is an empty project create some dummy files:
touch file.ctouch file.hgit initgit add file.*git commit -m "Initial commitStep 7. Configure remote server and push to the remote repository
git remote add origin ssh://git@<host>:/home/git/project.gitgit remote -vgit push origin masterStep 8. Clone to other Windows clients
git clone git@<host>:projects.git .Step 9. Setup GitHub Desktop application
Step 10. Test it