Last active
August 29, 2015 14:25
-
-
Save trungnt13/ba285d49f1b6e3bb61c5 to your computer and use it in GitHub Desktop.
Setup Git private server
This file contains 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
############################################################## | |
# Client | |
############################################################## | |
mkdir [repo] && cd [repo] | |
git init | |
git add -A | |
git commit -m "Init git repo" | |
############################################################## | |
# Server | |
############################################################## | |
# init git repo on server | |
mkdir [repo].git && cd [repo].git | |
git init --bare | |
# init hook to update web root | |
mkdir [path/to/web_root] | |
# in current git repo folder, GIT_WORK_TREE will transfer all data to web_root | |
# seperate from .git file | |
cat > hooks/post-receive | |
#!/bin/sh | |
GIT_WORK_TREE=[path/to/web_root] git checkout -f | |
# Ctrl + D | |
chmod +x hooks/post-receive | |
############################################################## | |
# Client | |
############################################################## | |
#example: git remote add origin ssh://ubuntu@192.168.1.13/home/ubuntu/src.git | |
git remote add [name_of_remote] ssh://server.example.org/home/ams/website.git | |
git push [name_of_remote] +master:refs/heads/master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment