Inspired by https://github.com/golang/go/wiki/Modules
In this page, I list my approach of starting a new Python project and have it Git initiated and commited to GitHub.
The idea here is to have a short stub as a starting point where I can then start adding code quickly.
1. Install hub#
hub is the command line tool used to communicate with GitHub. You can easily install it using brew.
brew install hub2. Create the repo in GitHub#
APP_NAME="my-new-python-projectx"
APP_DIR="/your/app/path/you/want/to/use"
mkdir -p $APP_DIR/$APP_NAME
cd $APP_DIR/$APP_NAME
cat <<EOF > main.py
def main():
print("Hello World!")
if __name__ == "__main__":
main()
EOF
wget -q https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore -O .gitignore
touch README.md requirements.txt
pyenv virtualenv $APP_NAME
git init -q
git remote add origin https://github.com/obay/$APP_NAME
git add .
git commit -m "Initial import"
hub create -p
git push --set-upstream origin master
code .