Last active
January 2, 2016 18:49
-
-
Save ajcrites/8346126 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# create the repository folder locally | |
~ $ mkdir project | |
~ $ cd project | |
# initialize git for this project | |
~/project $ git init | |
# create a file so the repository is not empty. | |
# Otherwise, you can't push it. | |
# Projects usually have a README associated with them, | |
# so this is a good choice for a default file | |
# `touch` just creates the file. You could create | |
# it by any other means if you wanted. | |
~/project $ touch README.md | |
# You need an initial commit so you have something | |
# to push to github. The `-m` option allows you to | |
# write a commit message inline. "Initial commit" | |
# could say anything, but since you haven't even done | |
# anything yet and this is just to initialize the repo, | |
# this is a sane commit message. | |
~/project $ git add README.md | |
~/project $ git commit -m "Initial commit" | |
# `git remote` sets up your configuration for communication | |
# with remote projects (i.e. projects on other machines) | |
# You will usually only have one of these: `origin`, the Github | |
# repository. You may have others such as `heroku`. | |
# | |
# Note that there is nothing special about `origin`. You | |
# can name the remote whatever you want. `origin` is | |
# a very common name for the agreed-upon central repository. | |
# In the example below, the project must already exist | |
# on github | |
~/project $ git remote add origin [email protected]:/username/project.git | |
# This pushes the commits you just made to `origin` | |
# for the specified branch (in this case `master`). | |
# The `-u` switch makes it so that `origin` is the | |
# default upstream branch (equivalent to | |
# `--set-upstream`). The upstream repository will | |
# generally be Github since this is the agreed | |
# upon central repository for the code. | |
# | |
# Once you have use `-u`, you don't need to | |
# use it again, and you can also leave `origin` | |
# off the push/pull commands since git now knows | |
# to use it by default thanks to `-u`. | |
~/project $ git push -u origin master |
This file contains hidden or 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
# Make sure that you are on the develop branch | |
~/project $ git checkout develop | |
# If you used `-u` already, just do this | |
~/project $ git pull develop | |
# Otherwise, try... | |
~/project $ git pull -u origin develop |
This file contains hidden or 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
~/project $ git checkout -b feature/EP-001 |
This file contains hidden or 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
# Example of a good commit message. | |
# Git ignores all lines in these messages | |
# that start with `#` by default, but you | |
# can change what meta character this is | |
EP-001: Adding a new blog entry about git-flow | |
In order to get this article to work with the | |
current blog setup, I had to move some of the | |
files to new locations. | |
* index.html -> 1.html | |
* 1.html -> 2.html | |
* 2.html -> 3.html | |
I also refreshed my memory about how to embed | |
specific gist files [thanks to Stackoverflow | |
once again](http://stackoverflow.com/questions/14206307/how-do-i-embed-a-single-file-from-a-github-gist-with-the-new-gist-interface) | |
<script src="gist-path?file=filename.ext"> |
This file contains hidden or 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
# Example of a bad commit message | |
# Note the missing tracking number | |
Added new article about git flow and moved a whole bunch of files around. | |
Included new gists using the embed with gist file special handling I got from Stackoverflow or somewhere. |
This file contains hidden or 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
# When Github displays a list of commits, | |
# it does so using the `--pretty=online` | |
# format. This is a compact way to view | |
# the log of commits. | |
~/project $ git log --pretty=online | |
dc5199ebf32da86662a7289cc87c27dd072418a0 EP-001: Adding a new blog entry about git-flow | |
873bf3c78cbbbb679bb081a7448f7cba36fbbc6c Added new article about git flow and moved a whole bunch of files around. Included new gists using the embed with gist file special handling I got from Stackoverflow or somewhere. |
This file contains hidden or 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
#!/bin/bash -e | |
# acquire the name of the current branch | |
current_branch=$(git branch --no-color | \grep '^\* ' | \grep -v 'no branch' | sed 's/^* //g') | |
git checkout develop | |
git pull | |
# Pray you don't have merge conflicts | |
# The script will exit if you do | |
git rebase develop $current_branch | |
git push origin $current_branch | |
git pull-request -b ProjectOwner:develop -h ProjectOwner:$current_branch | |
git checkout develop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment