Last active
August 18, 2016 14:50
-
-
Save VeeeneX/9bd72671f66c72d22bcea96ec4b6e9dc to your computer and use it in GitHub Desktop.
Sh (Subprocess) vs Os
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
# Executed with output: | |
# Already on 'develop' | |
# Your branch is up-to-date with 'origin/develop'. | |
os.system('git --git-dir /tmp/app/.git --no-pager checkout -f develop') | |
# Git status returns: | |
# On branch develop | |
# Your branch is up-to-date with 'origin/develop'. | |
# nothing to commit, working directory clean | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sh import git | |
# Steps | |
# 1. Clone branch to folder | |
# 2. Switch branch | |
# Executed 2 times with output: | |
# Already on 'develop' | |
# Your branch is up-to-date with 'origin/develop'. | |
for line in git.checkout("-f", branch, _err_to_out=True, _iter=True): | |
print(line) | |
# Git status returns: | |
# deleted: docker-compose-dev.yml | |
# modified: src/index.html | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment