Git_Workflow_and_Notes - UW-Libraries/druw GitHub Wiki
The master of this document lives at:
https://github.com/UW-Libraries/druw/wiki/Git_Workflow_and_Notes
Vagrant will set up a generic identity for your commits, so you'll want to change the defaults. You can run these commands in any directory as they make a global change.
- Set your user name:
git config --global user.name "Jane Doe"
- Set your e-mail:
git config --global user.email [email protected]
-
Clone repo:
git clone [email protected]:UW-Libraries/druw.git
-
Checkout a new branch with a name indicative of what you will be working on:
git checkout -b <branchname>
Note: One will often name a branch partly after its issue # on github/bitbucket. like:
git checkout -b 23_fix_widgets
so when I work on my commit message, i can do: "Add widget frobulation strategy to fix widget behavior. Fixes #23" which on github (and maybe on bitbucket?) will autoclose the referenced issue #.
Do what you came to do…
git add FILE1 FILE2 FILE3
-
git commit
orgit commit -m "Descriptive commit message"
git push origin <branchname>
When ready to add commits to main repo, make sure your forked branch is in sync with the main master before creating a pull request on UW-Libraries/druw
-
git checkout master
-
If you haven't previously, add UW-Libraries/druw as an additional remote repo for pulls:
git remote add upstream [email protected]:UW-Libraries/druw.git
You only have to do this the first time you rebase a given clone.
-
git pull upstream master
-
git checkout <branchname>
-
git rebase master
-
git push origin <branchname>
-
Copy that pull request url into a browser and continue or just go to the bitbucket gui to create the pull request. Have someone else review and merge your pull request.
- Create a bitbucket account if you don't have one.
- Fork the druw repo according to bitbucket instructions for forking
- Get your dev environment going. Docker containers and druw application
- Edit metadata spreadsheet to indicate you've started working on a term.
- Vaguely follow the above instructions to add a new term.
- Once rspec tests pass, create a pull request
If you have been working on the master branch and have not committed any of your changes, you can still turn your existing work into a branch.
- git branch somename master or git checkout -b my_branch
- make changes and add and commit them
git commit -a -m "Adding accrual_policy to metadata options" - make sure master is up to date
git checkout master
git pull - return to branch and push
git checkout branch
git push origin [ branch ] - Copy that pull request url into a browser and continue or just go to the bitbucket gui to create the pull request. Check 'delete branch after merge' or somesuch.
- After PR is merged, update local master and tag for production
git checkout master
git pull #to update master
git tag production-[date]
git push origin --tags or
git push origin [tagname]
- git checkout [ branch ]
- git rebase -i HEAD~# (where # is the number of commits to squish) == git rebase -i HEAD^^^^
- (This is where you'll drop into vi and change line 1 from "pick" to "reword", and change lines 2-3 from "pick" to "fixup)
- (That should work A-OK, and you shouldn't have merge conflicts)
- git push origin [branch] -f (note: don't ever use the -f when pushing to a shared repo)
pretty git history
git log --pretty=format:"%C(yellow)%h\ %Cgreen%ad\%Cblue\ %an%Cred%d\ %Creset%s" --graph --decorate --date=short
git pull vs. git fetch
- git pull is an alias for fetch and merge
- git fetch just fetches
- https://github.com/projecthydra/hydra/blob/master/CONTRIBUTING.md
- http://ndlib.github.io/practices/one-commit-per-pull-request/
- https://github.com/psu-stewardship/scholarsphere/wiki/Git-basics
- https://github.com/psu-stewardship/scholarsphere/wiki/Git-branch-workflow
- https://github.com/psu-stewardship/scholarsphere/wiki/Sample-git-config