How can I prevent git from clicking if local changes are detected (including files without a trace)?

Sometimes someone from our team does git push and breaks the assembly because its local assembly works, but he forgot to transfer all his local modifications and unverified files to git before he clicks.

I would like to prevent this ... I poured documents in an hour or so today and could not find anything built-in.

Does anyone have any solutions?

+5
source share
5 answers

You can use the hook pre-push(starting with git 1.8.2).

git status, 0 (, ), git status , 1 ( push).

git-status :

HEAD (.. git commit) , .

, git 1.8.2 , pre-push.sample .git/hooks, . pre-push : http://blog.ittybittyapps.com/blog/2013/09/03/git-pre-push/

, . , . ( . git, , . Makefile script, .)

+5

(, ), , . , git status , .

0

, -a. git-commit :

, git .

, git commit , . , git add . , , .

0

, , git config, push script, git " "? , , , . , , .

0

ant , ... ... , - .

, .

<target name="git-status-check">
    <echo>Performing git working directory check for local modifications or untracked files.</echo>
    <exec executable="git" failifexecutionfails="true"
        outputproperty="git.check">
        <arg value="status"/>
    </exec>
    <echo>${git.check}</echo>
    <propertyregex property="dirty.working.dir" input="${git.check}" regexp="working directory clean" 
        select="\1" casesensitive="false" />
    <fail message="Git status reports that you have local modifications or untracked changes in your working dir... did you forget to commit these changes? ${line.separator} ">
        <condition>
            <not>
                <isset property="dirty.working.dir" />
            </not>
        </condition>
    </fail>
    <echo>Git status reported a clean working dir continuing build...</echo>
</target>
0

All Articles