-
Notifications
You must be signed in to change notification settings - Fork 5
Home
ns-echen edited this page Jul 23, 2015
·
8 revisions
This git workflow description was forked from https://github.com/therewasaguy/p5con. Thanks for putting together this doc!
- Discussion --> Issues
- Bug reports
- Feature Requests
- Code --> Pull Requests
- Bug Fix
- New Feature
- Documentation
- Example
- Tests
-
Fork, Clone, Configure Remotes, Install Dependencies
- Fork https://github.com/NarrativeScience/lsi to your github account.
- Clone your fork of the repo from Terminal:
``git clone https://github.com//lsi``
- Navigate to the newly cloned directory: ``cd lsi``
- Add a reference to the original repo as a remote called "upstream":
<pre><code>git remote add upstream https://github.com/NarrativeScience/lsi</code></pre>
- Install Dependencies:
<pre><code>
``virtualenv venv``
``source venv/bin/activate``
``pip install -r requirements.txt``
``python setup.py develop``</code></pre>
-
Get Latest Changes
- If you cloned a while ago, get the latest changes from upstream:
-
git checkout master
--> switch to your "master" branch -
git pull upstream master
--> pull changes from the "master" branch of the remote repo we called "upstream"
-
-
Create a new branch
-
git checkout -b <topic-branch-name>
-
-b
creates the branch -
checkout
makes this your current branch. Updates all the files to reflect whatever’s in that branch -
checkout -b
does both at the same time. - This is a good idea in case your PR is not accepted right away, and you want to work on something else in the meantime. Because any commits you make to a branch with an unresolved pull requests will be added to the pull request.
-
-
Commit Your Changes
-
git add <files you want to include>
-git commit -m <your short commit message>
- Commit messages should explain the change(s) you made. - If you have a messy commit history, you can use git rebase to tidy up before sending the pull request. -
Push To Your Fork
-
git push origin <topic-branch-name>
- Open Pull Request - GitHub info on Using Pull Requests - Clear description of changes, clear title, imperative tense (i.e. "fix bug")
- Discuss & Amend Pull Request - Pull Requests can be discussed, just like issues - Pull Requests are not static snapshots of your repo. They update whenever you add more commits to the branch, until the PR is accepted.
-
git remote -v
List all your remotes "verbosely" git pull <name_of_the_remote> <branch_name>
git push <name_of_the_remote> <branch_name>
-
git checkout -b <topic-branch-name>
Create a new branch and check it out -
git stash
Stash all uncommitted changes you’ve made to the branch. You can get them back later. -
git log
Show commit history. -
git status
Show branch and pending changes. -
git diff
View merge conflicts -
git grep "something()"
Search for things in your working directory. -
git commit --amend
Amend your previous commit rather than creating a new commit
- Conflicts occur when branches have conflicting modifications that cannot be automatically resolved/merged. When you try to merge (i.e. pull upstream changes), if there are conflicts, git tells you and adds this stuff to your file:
<<<<<<< HEAD
Here is what you had locally
=======
Here is what was in the thing you tried to merge
>>>>>>> 59685c301d09b58fdac23d616
You can fix manually by picking which one you want and getting rid of all this: <<<<<< HEAD ======= >>>>> 583….