Skip to content

Commit cd24522

Browse files
authored
Create AutomatingGITPush
1 parent 4696f8e commit cd24522

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

GIT/AutomatingGITPush

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Write a simple bash script and save it on your home directory with git-push.sh
2+
3+
4+
echo "Enter your message"
5+
read message
6+
git add .
7+
git commit -m"${message}"
8+
if [ -n "$(git status - porcelain)" ];
9+
then
10+
echo "IT IS CLEAN"
11+
else
12+
git status
13+
echo "Pushing data to remote server!!!"
14+
git push -u origin master
15+
fi
16+
17+
18+
Now, we will make this file an executable file by changing the permission using chmod command.
19+
chmod +x git-push.sh
20+
or
21+
chmod 755 git-push.sh
22+
23+
24+
Once the script is executable we will need to copy it to a directory that in our system expects to contain executable scripts and code.
25+
On most systems we will have a choice between two directories.
26+
If we are the only user of our system you can copy our script to either /usr/bin or /usr/local/bin.
27+
If you share your system with other people it's best to copy your script to /usr/local/bin.
28+
You will most likely need super-user privileges to copy our script to either of these directories so most likely we need to use the sudo command.
29+
30+
31+
sudo cp git-push.sh /usr/bin/git-push.sh
32+
sudo cp git-push.sh /usr/local/bin
33+
34+
35+
This will make our script accessible globally so that we can use it from anywhere and anytime we want.
36+
37+
Alt Text
38+
39+
Moreover, if you want to make push scheduled over particular time you can use crontab job scheduler to do so.

0 commit comments

Comments
 (0)