shell - How to keep a folder up-to-date with a git repo? -
this shell script periodically check github latest code, , download, compile, , run if there difference between have locally , pulled.
i know can clone new directory, , check changes, , go there, seems incredibly wasteful, git should have logic checking differences between files , updating those.
to complicate matter, "local" version may @ point "latest" version, , in case want discard "new" changes , pull "stable" repository
i have this:
status=`cd $gitdir && git pull` if [ "$status" != "already up-to-date." ]; cd $gitdir && git fetch origin cd $gitdir && git reset --hard origin/master but fails when "local" "newer" - suggestions?
update: have looked clean option, gets rid of files excluded in .gitignore - want solution leave alone, discards changes source files , pulls latest github.
update #2: think need:
git fetch --all git reset --hard origin/master but need testing, confirmation looking nice
update #3: seems either
git reset --hard origin/master git reset --hard head works far overwriting local files, how know when 2 different (looking git diff.. )
first, since git 1.8.5 (nov 2013), you can utilize -c alternative git, in "git --git-dir not working expected".
status=`git -c $gitdir pull` if [ "$status" != "already up-to-date." ]; git -c $gitdir fetch origin git -c $gitdir reset --hard origin/master second, hear on client json payload coming github webhook triggered on push github repo. way, wouldn't have execute script unless needed.
git shell github automation
No comments:
Post a Comment