Last active
December 27, 2015 02:29
-
-
Save wasade/7252548 to your computer and use it in GitHub Desktop.
Mini github workflow example
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
# on github, go the your favorite repository, such as pyqi: | |
# https://github.com/bipy/pyqi | |
# click fork, this will create a copy of the forked repository (and branch, generally its master by default) | |
# on the command line, this will create a ./pyqi directory | |
$ git clone https://github.com/wasade/pyqi | |
$ cd pyqi | |
# update your remotes, this allows you to get updates from the master "origin" repository (bipy/pyqi in this case) | |
# we're going to call this upstream as it is upstream of your fork since other people merge to it | |
$ git remote add upstream https://github.com/bipy/pyqi | |
# sync just to be sane, we're going to pull down the master branch from upstream | |
$ git pull upstream master | |
# sync your fork on github | |
$ git push | |
...now we can do some coding. | |
# create a new branch and check it out | |
$ git checkout -b foo | |
# edit files, create files, delete files, etc | |
$ git add <each file or directory you want to commit> | |
$ git commit | |
... repeat ... | |
# push to origin (your fork) the branch you're working on | |
$ git push origin foo | |
# go to your github fork page, select the branch and click "issue pull request" | |
# It seems like a bit much at first, but gets to become very natural very quickly. Also, Yoshiki (ElDeveloper) has a nifty git function that updates your prompt to show what repo you're in (code below). And, last, you can add tab completion to git so you can tab out commands, branches, etc. Very handy, can be found here: | |
# https://github.com/git/git/blob/master/contrib/completion/git-completion.bash | |
# add to your ~/.bash_profile (written originally by Yoshiki Vazquez Baeza: | |
function egit (){ | |
# git specific usage for branching | |
function branch_separator () { | |
#git name-rev HEAD 2> /dev/null | sed 's#HEAD\ \(.*\)#(git::\1) #' | |
if [[ -n $(git rev-parse --abbrev-ref HEAD 2> /dev/null) ]] | |
then | |
echo "@" | |
fi | |
} | |
function get_git_branch () { | |
git rev-parse --abbrev-ref HEAD 2> /dev/null | |
} | |
export PS1='\[\033[1;32m\]\t \[\033[0m\]\W$(branch_separator)\[\e[m\]\[\e[01;38;5;196m\]$(get_git_branch)\[\e[m\]$ ' | |
} | |
function dgit (){ | |
export PS1='\[\033[1;32m\]\t \[\033[0m\]\W$ ' | |
} | |
# enable git flavored prompt | |
egit; | |
# add this if you have the git bash completion, or other bash completion scripts | |
for f in ~/.bash_completion.d/*; | |
do | |
source $f; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment