Skip to content

Instantly share code, notes, and snippets.

@davejlong
Created March 17, 2011 15:30
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save davejlong/874521 to your computer and use it in GitHub Desktop.
Save davejlong/874521 to your computer and use it in GitHub Desktop.
A simple ant script that will commit and push to a git repo.
<?xml version="1.0"?>
<project name="Demo" default="version" basedir=".">
<macrodef name="git">
<attribute name="command" />
<attribute name="dir" default="" />
<element name="args" optional="true" />
<sequential>
<echo message="git @{command}" />
<exec executable="git" dir="@{dir}">
<arg value="@{command}" />
<args/>
</exec>
</sequential>
</macrodef>
<target name="version" description="Commits all changes to version git">
<input message="Commit message" addproperty="commit-message" />
<echo message="Commiting all changes with message ${commit-message}" />
<git command="add">
<args>
<arg value="." />
</args>
</git>
<git command="commit">
<args>
<arg value="-am ${commit-message}" />
</args>
</git>
<git command="push" />
</target>
</project>
<macrodef name="git">
<attribute name="command" />
<attribute name="dir" default="" />
<element name="args" optional="true" />
<sequential>
<echo message="git @{command}" />
<exec executable="git" dir="@{dir}">
<arg value="@{command}" />
<args/>
</exec>
</sequential>
</macrodef>
<target name="version" description="Commits all changes to version git">
<input message="Commit message" addproperty="commit-message" />
<echo message="Commiting all changes with message ${commit-message}" />
<git command="add">
<args>
<arg value="." />
</args>
</git>
<git command="commit">
<args>
<arg value="-am ${commit-message}" />
</args>
</git>
<git command="push" />
</target>
@subhanu-trainee1
Copy link

ohh this not good

@Ankitdet
Copy link

Please provide good implementation...

@PrieurBenjamin
Copy link

A script working perfectly at the first try. Nice work !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment