You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Automated script for creating simple Git workflow
2
+
3
+
This project is in details described here [Create simple GIT workflow with automated script, like on GitHub].
4
+
5
+

6
+
7
+
Basic idea of this script is to skip using FTP/clients, scp or rsync for code upload to remote server. Instead this script will help you create robust Git workflow which involves protected bare Git repository and public repository which is served to visitors.
8
+
9
+
Public repository is mirror of bare repository. And bare repository is communication hub between your local development machine and public repository.
10
+
11
+
In couple of seconds you can create new repositories in a same way as you create them here on GitHub. One huge plus is that repository will be connected to public folder of your project via Git hooks.
12
+
13
+
14
+
[Create simple GIT workflow with automated script, like on GitHub]:http://tuts.codingo.me/create-simple-git-workflow-with-automated-script-like-on-github/
echo"Please enter ABSOLUTE PATH of web server public folder for this project, that will be your publicly visible web folder (for Apache /var/www/html/...)"
6
+
read webFolderPath
7
+
whiletrue;do
8
+
read -p "You entered: $webFolderPath is that correct path? y/n?" yn
9
+
case$ynin
10
+
[Yy]* ) mkdir -p $webFolderPath;break;;
11
+
[Nn]* ) echo"Script stopped";exit;;
12
+
* ) echo"Please answer yes or no.";;
13
+
esac
14
+
done
15
+
16
+
#cd into public folder and initialize git there
17
+
cd$webFolderPath; git init;
18
+
19
+
#take path of bare git repository and create it
20
+
echo"Please enter ABSOLUTE PATH of bare git repo, that will be you main entry point for pushing/pulling to remote server, one that ends with .git: "
21
+
read gitBareRepo
22
+
whiletrue;do
23
+
read -p "You entered: $gitBareRepo is that correct path? y/n?" yn
24
+
case$ynin
25
+
[Yy]* ) mkdir -p $gitBareRepo;break;;
26
+
[Nn]* ) echo"Script stopped";exit;;
27
+
* ) echo"Please answer yes or no.";;
28
+
esac
29
+
done
30
+
31
+
#cd into git bare repository and initialize bare repository there
32
+
cd$gitBareRepo; git init --bare;
33
+
34
+
#define bare repository as hub of public folder
35
+
cat <<EOT > $webFolderPath"/.git/config"
36
+
[remote "hub"]
37
+
url = $gitBareRepo
38
+
fetch = +refs/heads/*:refs/remotes/hub/*
39
+
EOT
40
+
41
+
#create post-update hook in git bare repository, for syncing files with public folder
42
+
cat <<EOT > $gitBareRepo"/hooks/post-update"
43
+
#!/bin/sh
44
+
echo
45
+
echo "**** Pulling changes into Live [Hub's post-update hook]"
46
+
echo
47
+
cd $webFolderPath || exit
48
+
unset GIT_DIR
49
+
git pull hub master
50
+
exec git-update-server-info
51
+
EOT
52
+
53
+
#create post-commit to sync back with bare repository,
54
+
#if you decide to change something directly from public folder
0 commit comments