<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Saurav Jaiswal</title>
    <description>The latest articles on DEV Community by Saurav Jaiswal (@sauravjaiswalsj).</description>
    <link>https://dev.to/sauravjaiswalsj</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F307875%2F720c38df-8e9c-4d56-969f-f80c33d25319.jpeg</url>
      <title>DEV Community: Saurav Jaiswal</title>
      <link>https://dev.to/sauravjaiswalsj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sauravjaiswalsj"/>
    <language>en</language>
    <item>
      <title>Automating git push with just a single bash command</title>
      <dc:creator>Saurav Jaiswal</dc:creator>
      <pubDate>Fri, 01 May 2020 10:18:43 +0000</pubDate>
      <link>https://dev.to/sauravjaiswalsj/automating-git-push-with-just-a-single-bash-command-460n</link>
      <guid>https://dev.to/sauravjaiswalsj/automating-git-push-with-just-a-single-bash-command-460n</guid>
      <description>&lt;p&gt;Say you are working on a project or learning something or doing challenge like #100daysofcode and you are only person who is committing files to the github repository. Wouldn't it be great if we could make whole git process automated instead of typing every time same git commands to push file on to github repository. &lt;/p&gt;

&lt;p&gt;We can do a simple hack to automate the whole process with just one bash command. Yes! you heard it right. One bash command can push entire repository from you local machine to github.&lt;/p&gt;

&lt;p&gt;So lets start by writing a simple bash script and save it on your home directory with git-push.sh&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo "Enter your message"
read message
git add .
git commit -m"${message}"
if [ -n "$(git status - porcelain)" ];
then
 echo "IT IS CLEAN"
else
 git status
 echo "Pushing data to remote server!!!"
 git push -u origin master
fi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Basically it is taking all the file from your folder and pushing it to the github. If condition checks it the files are already push or not. If it would have been already pushed then it will just return else it will push the files to the github repository.&lt;/p&gt;

&lt;p&gt;Now, we will make this file an executable file by changing the permission using chmod command.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;chmod +x git-push.sh&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;chmod 755 git-push.sh&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;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. On most systems we will have a choice between two directories. If we are the only user of our system you can copy our script to either /usr/bin or /usr/local/bin. If you share your system with other people it's best to copy your script to /usr/local/bin. 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.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo cp git-push.sh /usr/bin/git-push.sh
sudo cp git-push.sh /usr/local/bin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will make our script accessible globally so that we can use it from anywhere and anytime we want.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---g5oDErl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/bseerqocizzytjlv3uv2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---g5oDErl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/bseerqocizzytjlv3uv2.jpg" alt="Alt Text" width="632" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Moreover, if you want to make push scheduled over particular time you can use crontab job scheduler to do so.&lt;/p&gt;

</description>
      <category>git</category>
      <category>bash</category>
      <category>linux</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
