Git script is running differently when I run it through subprocess.check_output?


When I run this Bash script


cd /srv/http
unset GIT_DIR

git commit -am "design changes"
git push -u origin master
git checkout dev
git merge master
git commit -am "design changes"
git checkout master

through the command line, I get this output

[master 914422f] design changes
 1 file changed, 17 deletions(-)
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 334 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
To https://[email protected]/blah/blah.git
   562207f..914422f  master -> master
Branch master set up to track remote branch master from origin.
Switched to branch 'dev'
Updating 562207f..914422f
 save-design | 17 -----------------
 1 file changed, 17 deletions(-)
On branch dev
nothing to commit, working directory clean
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.

but when I run it through Python using

subprocess.check_output('./save-design', shell=True)

I get this output

M   save-design
Already up-to-date.
M   save-design
Your branch is up-to-date with 'origin/master'.

Why does this happen?


I still don’t know why it’s happening, but I fixed it by running it by sshing to localhost:

subprocess.check_output('ssh localhost "/srv/http/save-design"', shell=True)

Answered By – user2058002

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published