Personal tools

Difference between revisions of "Auto clear temp. dir on pull"

From PhotoVoltaic Logger new generation

Jump to: navigation, search
(Created page with "If you cloned PVLng by git, you should clear the temp. directory after each <tt>git pull</tt>. To automate this, you can put the following code into <tt>.git/hooks/post-merge...")
 
m
Line 3: Line 3:
 
To automate this, you can put the following code into <tt>.git/hooks/post-merge</tt>:
 
To automate this, you can put the following code into <tt>.git/hooks/post-merge</tt>:
  
  #/bin/sh
+
  #!/bin/sh
 +
# MIT © Knut Kohl - https://gist.github.com/K-Ko
 +
# Git hook to clear temp. directory after `git pull`
 
  #
 
  #
  # MIT © Knut Kohl - <nowiki>https://github.com/KKoPV</nowiki>
+
  # .git/hooks/post-merge
#
 
# Git hook to clear temp. directory after 'git pull'
 
 
  #
 
  #
 +
# Don't forget to make executalbe by `chmod 755 post-merge`
 +
 
  echo
 
  echo
 
  echo -n 'Empty temp. directory ... '
 
  echo -n 'Empty temp. directory ... '
 +
 
  find tmp -type f ! -empty -delete
 
  find tmp -type f ! -empty -delete
 +
 
  echo Done.
 
  echo Done.
 +
 +
You can get it also from this Gist:
 +
 +
# wget -qO .git/hooks/post-merge https://gist.github.com/K-Ko/e7c01e0c7490ee4352fb
  
 
Make the script executable by
 
Make the script executable by

Revision as of 13:32, 14 May 2014

If you cloned PVLng by git, you should clear the temp. directory after each git pull.

To automate this, you can put the following code into .git/hooks/post-merge:

#!/bin/sh
# MIT © Knut Kohl - https://gist.github.com/K-Ko
# Git hook to clear temp. directory after `git pull`
#
# .git/hooks/post-merge
#
# Don't forget to make executalbe by `chmod 755 post-merge`

echo
echo -n 'Empty temp. directory ... '

find tmp -type f ! -empty -delete

echo Done.

You can get it also from this Gist:

# wget -qO .git/hooks/post-merge https://gist.github.com/K-Ko/e7c01e0c7490ee4352fb

Make the script executable by

# chmod +x .git/hooks/post-merge

and you are done.

Next time, you pull changes from Github, the hook will remove all not empty files from temp. directory (this will ignore the .githold file)