Setup Bare Git Repo
Login to Remote Server
ssh [email protected]
Create Bare repo
cd parent.folder
git init --bare ~/bareRepoName.git
Setup Local Repo and Push to Remote Bare Repo
mkdir mylocalproject
cd mylocalproject
git init
git add.
git commit -m "Initial commit"
git remote add origin ssh://[email protected]/~/mybareproject.git
git push -u origin main
[Optional] Prepare Ansible Playbook for Reuse
---
- name: Create a bare Git repository on the remote server
hosts: remoteServer
become: yes # If you need elevated privileges to create the directory, set this to yes
tasks:
- name: Create the directory for the bare repository
file:
path: /home/{{ ansible_user }}/mybareproject.git
state: directory
mode: '0755'
- name: Initialize the bare Git repository
command: git init --bare
args:
chdir: /home/{{ ansible_user }}/mybareproject.git