Pages

Thursday, February 4, 2021

Add a bare git repository on Server and auto update in different target directory

 CREATE AUTO UPDATE FILES IN REPOSITIRY on SSH Ubuntu Server

=> Login in SSH account

=> create directory repos in var directory
cd /var/repos/

=> Create bare repository
git clone --bare gitrepo.git


=> create file by typing this command

sudo nano /var/repos/gitrepo.git/post-receive

=> change file (post-receive) permissions to 755

=> Add Content in file

#!/bin/sh
git --work-tree=/var/www/html/gitrepotarget/ --git-dir=/var/repos/gitrepo.git/ checkout -f



=> save File

=> the Repository is ready to push and clone

=> git clone ssh://root@123.45.67.8:/path/to/repository.git

=> enter password for Server login


Git Repository Branches:

-- create new branch
=> git checkout -b Zahid

Switch to branch

=> git checkout Zahid

make some changes and (git add .) and (git commit -m "Commit message from Zahid Branch")

-- to merge changes in main 

=>git checkout master

=> git pull

=> git merge Zahid 

then check status

=> git status

=> git push origin master (The git push should be from Master)


No comments:

Post a Comment