Git pushing to non-bare repo, save current worktree -


how can push non-bare git repository, automatically add , commit changes in working tree, , re-checkout current branch reflect changes push?

i thinking of this:

add hook on remote (the non-bare repo) run git add . && git commit -m "automated commit" && git reset --hard

are there drawbacks method? there way of doing this?


(disclaimer: know isn't ideal situation, have @ company , want make streamlined possible without needing change way things)

thanks!

after messing around found pretty solution.

pre-receive hook: checks changes in working directory, adds/commits them, alerts user he/she needs merge before pushing

#!/bin/sh cd ../ unset git_dir changed=$(git diff-index --name-only head --) if [ -n "$changed" ];     git add -u .     git commit -m "automated commit"     echo "there uncommitted changes in working directory...please pull them , push changes again"     exit 1 fi  

post-receive hook: force checks-out current branch changes shown in working directory. overwrite changes in working directory, have been added/committed/merged pre-receive hook.

#!/bin/sh cd ../ unset git_dir branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')  git checkout -f $branch   echo "update pushed branch $branch , checked out in website directory"  

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -