SlideShare a Scribd company logo
1 of 38
Ben Emmons
Web & Mobile Services, UITSGit and BitBucket
Prerequisites
10/22/2013
• Basic understanding of version control and Git
(see Mike Hagedon’s presentation for a refresher)
• Acknowledge that Git is better than the competition
(let’s not waste time on flame wars)
• command line is your friend 
Source:
Google Trends
Agenda
10/22/2013
• Local
• Git config – go beyond user.name and user.email
• Start with goal in mind – desired end-state
• Workflow – remote repositories, branches, submodules
• When things go wrong…
• Remote
• SSH
• BitBucket
• Pro Tips & Additional resources
Git config – user (a.k.a. minimum compliance)
10/22/2013
• git config --global user.name `whoami`@`hostname|cut -d"." -f1`
• git config --global user.email `whoami`@`hostname`
Source: yilb.com
Git config – core
10/22/2013
• git config --global core.autocrlf input
• git config --global core.whitespace trailing-space,space-before-
tab,indent-with-non-tab
Source: cheezburger.com
Git config – color
10/22/2013
• git config --global color.ui true
• git config --global color.diff.old "red bold"
• git config --global color.branch.remote "cyan"
• git config --global color.status.added "cyan"
• git config --global color.status.changed "cyan"
• git config --global color.status.untracked "magenta bold"
• git config --global color.status.nobranch "magenta bold"
Source: Mars, Inc. Source: Star Trek
Git config – alias
10/22/2013
• git log (default)
Git config – alias (git l)
10/22/2013
• git config --global alias.l 'log --graph --pretty=format:"%C(bold
yellow)%d%Creset %C(magenta)%h%Creset %C(blue)<%an>%Creset - %C(bold
white)%s%Creset %C(bold black)(%cr)%Creset" --abbrev-commit'
Git config – alias
10/22/2013
• git diff (default)
Git config – alias (git d)
10/22/2013
• git config --global alias.d 'diff --color-words'
Git config – alias
10/22/2013
• “svn revert” equivalent?
Git config – alias (git r)
10/22/2013
• sed '/[alias]/ atr = checkout -- ' -i ~/.gitconfig
Git config – alias
10/22/2013
• “svn info” equivalent?
Git config – alias (git info)
10/22/2013
• git config --global alias.info '!f() { local branch=`git rev-parse --abbrev-ref HEAD`; local url=`git config --
get remote.origin.url`; local status=`git status --porcelain $1`; local diff=`git diff --name-status
origin/$branch $branch $1`; local schedule=${status:0:1}${diff:0:1}; git log -n 1 --pretty=format:"Path:
`readlink -e $1`%nName: $1%nURL: `echo $url | sed -e "s/^ssh://git@/https:///" | sed -e
"s/.git$//src/HEAD//"`$1?at=$branch%nRepository Root: $url%nRepository UUID: `git log --reverse -1 --
format=%H`%nRepository Revision: `git log origin/$branch -n 1 --format=%h -- $1`%nNode Kind: `stat -c %F
$1`%nSchedule: %C(green)$schedule%Creset%nLast Commit Author: %cn <%ce>%nLast Commit Rev: `git log -n 1 --
format=%h -- $1`%nLast Commit Date: %ci %C(bold black)(%cr)%Creset%nLast Updated: `stat -c %y $1`%nChecksum:
`test -f $1 && md5sum $1 | cut -d " " -f 1`" -- $1; }; f'
Git config – alias
10/22/2013
• “svn status -u” equivalent?
Git config – alias (git check)
10/22/2013
• git config --global alias.check '!f() { local branch=`git rev-parse
--abbrev-ref HEAD`; git fetch origin --quiet && git diff --name-
status $branch origin/$branch $1; }; f'
Git config – alias
10/22/2013
• Other aliases (explained later)
• git config --global alias.changed 'diff-tree --no-commit-id --name-only
-r'
• git config --global alias.release '!git push; git tag -a "`date
+%Y%m%d`-`whoami`-`date +%s`" -m `date +%s`; git push --tags;'
• git config --global alias.hotfix '!git tag -a "`date +%Y%m%d`-`whoami`-
`date +%s`-hotfix" -m `date +%s`'
• git config --global alias.bleach '!git reset --hard -q; git clean -d -f
-n; read -p "Apply changes? (Y/n) " -n 1 -r; echo; if [[ $REPLY =~
^[Yy]$ ]]; then git clean -d -f; fi'
• Optional (ignores executable bit differences)
• git config --global core.filemode false
# git status
old mode 100755
new mode 100644
Agenda
10/22/2013
• Local
 Git config – go beyond user.name and user.email
• Start with goal in mind – desired end-state
• Workflow – remote repositories, branches, submodules
• When things go wrong…
• Remote
• SSH
• BitBucket
• Pro Tips & Additional resources
Goal
10/22/2013
3-tier version control with 10 or less daily commands:
• git status  checks local repo to see if there are any pending changes to
add/push
• git check  checks local and remote repo to see if there are any pending changes
• git pull  applies pending changes to local repo
• git info <file>  brief report on status of file
• git add <file> (or git add .)  adds a file (or many files) to git
• git rm <file>  deletes a version controlled file (normal rm works as well)
• git commit <file> -m 'My descriptive commit message' (or git commit -am 'My
descriptive commit message')  commits changes to local repo
• git push  pushes changes to remote repo branch
• git release  pushes changes to remote repo branch and tags it as a release
• https://bitbucket.org/<account>/<site>/pull-requests  review and pull changes
from one environment to another (e.g. test > master)
Agenda
10/22/2013
• Local
 Git config – go beyond user.name and user.email
 Start with goal in mind – desired end-state
• Workflow – remote repositories, branches, submodules
• When things go wrong…
• Remote
• SSH
• BitBucket
• Pro Tips & Additional resources
Workflow
10/22/2013
• Daniel Walker model (based on Vincent Driessen’s popular git-flow model)
Workflow (continued)
10/22/2013
• Single repository for Drupal core (dev/test/master) and separate
submodules for each sites directory (dev/test/master)
Workflow (continued)
10/22/2013
• .gitignore file: https://gist.github.com/anonymous/8610387
(note: the sites/* line includes a subtle hack to avoid tracking .gitmodules files in the Drupal
core repository; this will cause two side effects: a false error will be thrown upon submodule
creation and you need to run git commands in both core and site folders)
• Allow “git pull”: git checkout –t origin/master
• In DEV and TEST, delete master branch: git branch –d master
• Allow “git push”: git push –u origin master
• Use BitBucket pull requests to move code between branches
(more on this in a second…)
Agenda
10/22/2013
• Local
 Git config – go beyond user.name and user.email
 Start with goal in mind – desired end-state
 Workflow – remote repositories, branches, submodules
• When things go wrong…
• Remote
• SSH
• BitBucket
• Pro Tips & Additional resources
When things go wrong…
10/22/2013
Source: UniKeep
When things go wrong…
10/22/2013
Analyze
1. git l  see detailed info regarding recent commits
2. git changed <commit hash>  list files changed in specific commit
3. git d <path/to/filename>  see local modifications to a single file
4. git d <path/to/folder/> (or simply 'git d’ for current folder)  see local
modifications to all files within a folder (recursive)
5. git d <tagname> HEAD --stat  shows changed files between tagged release
and current local version
6. git d <tagname> HEAD <path/to/changed/filename>  shows change in
specific file between tagged release and current local file
When things go wrong…
10/22/2013
Undo
7. git r <path/to/filename>  revert local uncommitted modifications to a single file
8. git r .  revert all local uncommitted modifications within a folder (recursive)
9. git reset <path/to/filename>  reverts 'git add' of a single file
10. git reset .  reverts all 'git add' commands within a folder (recursive)
11. git reset --hard  reverts all file modifications and 'git add' commands
12. git clean -d -f -n .  dry-run test to see what untracked files would be deleted
within a folder (recursive)
13. git clean -d -f .  delete untracked files within a folder (recursive)
14. git bleach  reverts all file modifications and new/unignored files (does NOT
delete gitignored files/folders; use with caution)
Pro Tip: when in doubt, git stash
When things go wrong…
10/22/2013
Rollback
15. git commit --amend -m "New commit message"  change most recent
commit message
16. git reset HEAD~1 <or commit hash>  use to uncommit most recent commit
but keep modifications (ONLY use if commit is NOT pushed)
17. git reset --hard HEAD~1 <or commit hash>  use to fully rollback most recent
commit (ONLY use if commit is NOT pushed)
18. git revert HEAD <or commit hash>  use to fully rollback most recent pushed
commit (type ":wq" to accept the default commit message, then type "git push" to
submit the rollback)
Agenda
10/22/2013
• Local
 Git config – go beyond user.name and user.email
 Start with goal in mind – desired end-state
 Workflow – remote repositories, branches, submodules
 When things go wrong…
• Remote
• SSH
• BitBucket
• Pro Tips & Additional resources
SSH
10/22/2013
• Use Secure Shell (SSH) keys for communicating between servers:
ssh-keygen –t rsa –b 2048 –C your@email.com
• ~/.ssh/id_rsa file is your private key (protect like you would a password)
• ~/.ssh/id_rsa.pub file is your public key (share with anyone, including
BitBucket)
Agenda
10/22/2013
• Local
 Git config – go beyond user.name and user.email
 Start with goal in mind – desired end-state
 Workflow – remote repositories, branches, submodules
 When things go wrong…
• Remote
 SSH
• BitBucket
• Pro Tips & Additional resources
BitBucket
10/22/2013
• Why not GitHub ? BitBucket provides free, unlimited public and private
repositories for higher education
• Supports SSH keys: /account/user/<usename>/ssh-keys
• Supports Personal and Team accounts (with role-based groups and
authorization rules)
• Supports Pull Requests to pull changes from another repository or
branch
• Clean, intuitive interface with similar functionality to GitHub (wiki, issue
tracking, dashboard, etc.)
• Issue tracking integration with commit messages: http://goo.gl/HoC75k
• Integration options with other Atlassian products such as JIRA and
Confluence
BitBucket (continued)
10/22/2013
• On /account/user/<team account>/groups
o Set up Administrators, Developers, and Readers groups (Pro Tip: add Team
account username to Administrators group by typing full name since it may not appear
in auto-search)
• On /<account>/<repo>/admin/access (Pro Tip: gear icon in top-right is easy to miss)
o Add users and apply appropriate permission (usually “write”)
• On /<account>/<repo>/admin/branches
o Limit pushes for master to “<account>:administrators“ group
o Optionally limit pushes for test and dev
o Prevent deletion of master, test, dev branches (Pro Tip: due to BitBucket bug
when clicking on textbox initially you may get dropdown, but you must type name not
select from dropdown)
o Optionally prevent history re-writes (rebase)
BitBucket (continued)
10/22/2013
• When ready to move code from dev  test or test  master, use a Pull Request:
/<account>/<repo>/pull-request/new
Agenda
10/22/2013
• Local
 Git config – go beyond user.name and user.email
 Start with goal in mind – desired end-state
 Workflow – remote repositories, branches, submodules
 When things go wrong…
• Remote
 SSH
 BitBucket
• Pro Tips & Additional resources
Pro Tips
10/22/2013
• After a site is “live”, code only “moves upstream” (dev → test
→ master), except for TEST bug fixes and PROD hotfixes
• After a site is “live”, the database (content) and files only
“move downstream” (dev ← test ← master)
• Beware any git command including --force
DEV
PROD
Additional Resources
10/22/2013
• “Pro Git” eBook (free): http://git-scm.com/
• Other Git models:
• http://svn.haxx.se/users/archive-2007-10/att-
0101/SCMBranchingModels.pdf
• http://nvie.com/posts/a-successful-git-branching-model/
• Other Git workflows: https://www.atlassian.com/git/workflows
• http://gitignore.io/
• UITS Web & Mobile Services Git documentation (* restricted
access, complex, and customized to our environment so email me offline if you
want a copy):
http://confluence.arizona.edu/display/uitswt/GIT+and+BitBucket+documentation
10/22/2013
Questions?

More Related Content

What's hot

What's hot (20)

Bitbucket
BitbucketBitbucket
Bitbucket
 
Git with bitbucket
Git with bitbucketGit with bitbucket
Git with bitbucket
 
Difference between gitlab vs github vs bitbucket
Difference between gitlab vs github vs bitbucketDifference between gitlab vs github vs bitbucket
Difference between gitlab vs github vs bitbucket
 
Git tutorial
Git tutorial Git tutorial
Git tutorial
 
Introduction to git and github
Introduction to git and githubIntroduction to git and github
Introduction to git and github
 
BitBucket presentation
BitBucket presentationBitBucket presentation
BitBucket presentation
 
How we use Bitbucket to build Bitbucket
How we use Bitbucket to build BitbucketHow we use Bitbucket to build Bitbucket
How we use Bitbucket to build Bitbucket
 
Git and github fundamentals
Git and github fundamentalsGit and github fundamentals
Git and github fundamentals
 
AtlasCamp 2015: Bitbucket: Building kick-ass tools for 2.5M developers
AtlasCamp 2015:  Bitbucket: Building kick-ass tools for 2.5M developersAtlasCamp 2015:  Bitbucket: Building kick-ass tools for 2.5M developers
AtlasCamp 2015: Bitbucket: Building kick-ass tools for 2.5M developers
 
Git basics
Git basicsGit basics
Git basics
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
 
Bitbucket
BitbucketBitbucket
Bitbucket
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | Workshop
 
Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshare
 
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewGit and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
 
Github
GithubGithub
Github
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
HacktoberFest-Git&GitHub
HacktoberFest-Git&GitHubHacktoberFest-Git&GitHub
HacktoberFest-Git&GitHub
 
Workshop on Git and GitHub
Workshop on Git and GitHubWorkshop on Git and GitHub
Workshop on Git and GitHub
 
Git basics
Git basicsGit basics
Git basics
 

Similar to git-and-bitbucket

Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
Terry Wang
 

Similar to git-and-bitbucket (20)

Git training v10
Git training v10Git training v10
Git training v10
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
 
Git presentation
Git presentationGit presentation
Git presentation
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.com
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How to
 
Getting some Git
Getting some GitGetting some Git
Getting some Git
 
sample.pptx
sample.pptxsample.pptx
sample.pptx
 
Basic git
Basic gitBasic git
Basic git
 
簡單介紹git
簡單介紹git簡單介紹git
簡單介紹git
 
Advanted git
Advanted git Advanted git
Advanted git
 
Git basics
Git basicsGit basics
Git basics
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of Git
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
 
Git
GitGit
Git
 
Git & gitflow
Git & gitflowGit & gitflow
Git & gitflow
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmd
 

git-and-bitbucket

  • 1. Ben Emmons Web & Mobile Services, UITSGit and BitBucket
  • 2. Prerequisites 10/22/2013 • Basic understanding of version control and Git (see Mike Hagedon’s presentation for a refresher) • Acknowledge that Git is better than the competition (let’s not waste time on flame wars) • command line is your friend  Source: Google Trends
  • 3. Agenda 10/22/2013 • Local • Git config – go beyond user.name and user.email • Start with goal in mind – desired end-state • Workflow – remote repositories, branches, submodules • When things go wrong… • Remote • SSH • BitBucket • Pro Tips & Additional resources
  • 4. Git config – user (a.k.a. minimum compliance) 10/22/2013 • git config --global user.name `whoami`@`hostname|cut -d"." -f1` • git config --global user.email `whoami`@`hostname` Source: yilb.com
  • 5. Git config – core 10/22/2013 • git config --global core.autocrlf input • git config --global core.whitespace trailing-space,space-before- tab,indent-with-non-tab Source: cheezburger.com
  • 6. Git config – color 10/22/2013 • git config --global color.ui true • git config --global color.diff.old "red bold" • git config --global color.branch.remote "cyan" • git config --global color.status.added "cyan" • git config --global color.status.changed "cyan" • git config --global color.status.untracked "magenta bold" • git config --global color.status.nobranch "magenta bold" Source: Mars, Inc. Source: Star Trek
  • 7. Git config – alias 10/22/2013 • git log (default)
  • 8. Git config – alias (git l) 10/22/2013 • git config --global alias.l 'log --graph --pretty=format:"%C(bold yellow)%d%Creset %C(magenta)%h%Creset %C(blue)<%an>%Creset - %C(bold white)%s%Creset %C(bold black)(%cr)%Creset" --abbrev-commit'
  • 9. Git config – alias 10/22/2013 • git diff (default)
  • 10. Git config – alias (git d) 10/22/2013 • git config --global alias.d 'diff --color-words'
  • 11. Git config – alias 10/22/2013 • “svn revert” equivalent?
  • 12. Git config – alias (git r) 10/22/2013 • sed '/[alias]/ atr = checkout -- ' -i ~/.gitconfig
  • 13. Git config – alias 10/22/2013 • “svn info” equivalent?
  • 14. Git config – alias (git info) 10/22/2013 • git config --global alias.info '!f() { local branch=`git rev-parse --abbrev-ref HEAD`; local url=`git config -- get remote.origin.url`; local status=`git status --porcelain $1`; local diff=`git diff --name-status origin/$branch $branch $1`; local schedule=${status:0:1}${diff:0:1}; git log -n 1 --pretty=format:"Path: `readlink -e $1`%nName: $1%nURL: `echo $url | sed -e "s/^ssh://git@/https:///" | sed -e "s/.git$//src/HEAD//"`$1?at=$branch%nRepository Root: $url%nRepository UUID: `git log --reverse -1 -- format=%H`%nRepository Revision: `git log origin/$branch -n 1 --format=%h -- $1`%nNode Kind: `stat -c %F $1`%nSchedule: %C(green)$schedule%Creset%nLast Commit Author: %cn <%ce>%nLast Commit Rev: `git log -n 1 -- format=%h -- $1`%nLast Commit Date: %ci %C(bold black)(%cr)%Creset%nLast Updated: `stat -c %y $1`%nChecksum: `test -f $1 && md5sum $1 | cut -d " " -f 1`" -- $1; }; f'
  • 15. Git config – alias 10/22/2013 • “svn status -u” equivalent?
  • 16. Git config – alias (git check) 10/22/2013 • git config --global alias.check '!f() { local branch=`git rev-parse --abbrev-ref HEAD`; git fetch origin --quiet && git diff --name- status $branch origin/$branch $1; }; f'
  • 17. Git config – alias 10/22/2013 • Other aliases (explained later) • git config --global alias.changed 'diff-tree --no-commit-id --name-only -r' • git config --global alias.release '!git push; git tag -a "`date +%Y%m%d`-`whoami`-`date +%s`" -m `date +%s`; git push --tags;' • git config --global alias.hotfix '!git tag -a "`date +%Y%m%d`-`whoami`- `date +%s`-hotfix" -m `date +%s`' • git config --global alias.bleach '!git reset --hard -q; git clean -d -f -n; read -p "Apply changes? (Y/n) " -n 1 -r; echo; if [[ $REPLY =~ ^[Yy]$ ]]; then git clean -d -f; fi' • Optional (ignores executable bit differences) • git config --global core.filemode false # git status old mode 100755 new mode 100644
  • 18. Agenda 10/22/2013 • Local  Git config – go beyond user.name and user.email • Start with goal in mind – desired end-state • Workflow – remote repositories, branches, submodules • When things go wrong… • Remote • SSH • BitBucket • Pro Tips & Additional resources
  • 19. Goal 10/22/2013 3-tier version control with 10 or less daily commands: • git status  checks local repo to see if there are any pending changes to add/push • git check  checks local and remote repo to see if there are any pending changes • git pull  applies pending changes to local repo • git info <file>  brief report on status of file • git add <file> (or git add .)  adds a file (or many files) to git • git rm <file>  deletes a version controlled file (normal rm works as well) • git commit <file> -m 'My descriptive commit message' (or git commit -am 'My descriptive commit message')  commits changes to local repo • git push  pushes changes to remote repo branch • git release  pushes changes to remote repo branch and tags it as a release • https://bitbucket.org/<account>/<site>/pull-requests  review and pull changes from one environment to another (e.g. test > master)
  • 20. Agenda 10/22/2013 • Local  Git config – go beyond user.name and user.email  Start with goal in mind – desired end-state • Workflow – remote repositories, branches, submodules • When things go wrong… • Remote • SSH • BitBucket • Pro Tips & Additional resources
  • 21. Workflow 10/22/2013 • Daniel Walker model (based on Vincent Driessen’s popular git-flow model)
  • 22. Workflow (continued) 10/22/2013 • Single repository for Drupal core (dev/test/master) and separate submodules for each sites directory (dev/test/master)
  • 23. Workflow (continued) 10/22/2013 • .gitignore file: https://gist.github.com/anonymous/8610387 (note: the sites/* line includes a subtle hack to avoid tracking .gitmodules files in the Drupal core repository; this will cause two side effects: a false error will be thrown upon submodule creation and you need to run git commands in both core and site folders) • Allow “git pull”: git checkout –t origin/master • In DEV and TEST, delete master branch: git branch –d master • Allow “git push”: git push –u origin master • Use BitBucket pull requests to move code between branches (more on this in a second…)
  • 24. Agenda 10/22/2013 • Local  Git config – go beyond user.name and user.email  Start with goal in mind – desired end-state  Workflow – remote repositories, branches, submodules • When things go wrong… • Remote • SSH • BitBucket • Pro Tips & Additional resources
  • 25. When things go wrong… 10/22/2013 Source: UniKeep
  • 26. When things go wrong… 10/22/2013 Analyze 1. git l  see detailed info regarding recent commits 2. git changed <commit hash>  list files changed in specific commit 3. git d <path/to/filename>  see local modifications to a single file 4. git d <path/to/folder/> (or simply 'git d’ for current folder)  see local modifications to all files within a folder (recursive) 5. git d <tagname> HEAD --stat  shows changed files between tagged release and current local version 6. git d <tagname> HEAD <path/to/changed/filename>  shows change in specific file between tagged release and current local file
  • 27. When things go wrong… 10/22/2013 Undo 7. git r <path/to/filename>  revert local uncommitted modifications to a single file 8. git r .  revert all local uncommitted modifications within a folder (recursive) 9. git reset <path/to/filename>  reverts 'git add' of a single file 10. git reset .  reverts all 'git add' commands within a folder (recursive) 11. git reset --hard  reverts all file modifications and 'git add' commands 12. git clean -d -f -n .  dry-run test to see what untracked files would be deleted within a folder (recursive) 13. git clean -d -f .  delete untracked files within a folder (recursive) 14. git bleach  reverts all file modifications and new/unignored files (does NOT delete gitignored files/folders; use with caution) Pro Tip: when in doubt, git stash
  • 28. When things go wrong… 10/22/2013 Rollback 15. git commit --amend -m "New commit message"  change most recent commit message 16. git reset HEAD~1 <or commit hash>  use to uncommit most recent commit but keep modifications (ONLY use if commit is NOT pushed) 17. git reset --hard HEAD~1 <or commit hash>  use to fully rollback most recent commit (ONLY use if commit is NOT pushed) 18. git revert HEAD <or commit hash>  use to fully rollback most recent pushed commit (type ":wq" to accept the default commit message, then type "git push" to submit the rollback)
  • 29. Agenda 10/22/2013 • Local  Git config – go beyond user.name and user.email  Start with goal in mind – desired end-state  Workflow – remote repositories, branches, submodules  When things go wrong… • Remote • SSH • BitBucket • Pro Tips & Additional resources
  • 30. SSH 10/22/2013 • Use Secure Shell (SSH) keys for communicating between servers: ssh-keygen –t rsa –b 2048 –C your@email.com • ~/.ssh/id_rsa file is your private key (protect like you would a password) • ~/.ssh/id_rsa.pub file is your public key (share with anyone, including BitBucket)
  • 31. Agenda 10/22/2013 • Local  Git config – go beyond user.name and user.email  Start with goal in mind – desired end-state  Workflow – remote repositories, branches, submodules  When things go wrong… • Remote  SSH • BitBucket • Pro Tips & Additional resources
  • 32. BitBucket 10/22/2013 • Why not GitHub ? BitBucket provides free, unlimited public and private repositories for higher education • Supports SSH keys: /account/user/<usename>/ssh-keys • Supports Personal and Team accounts (with role-based groups and authorization rules) • Supports Pull Requests to pull changes from another repository or branch • Clean, intuitive interface with similar functionality to GitHub (wiki, issue tracking, dashboard, etc.) • Issue tracking integration with commit messages: http://goo.gl/HoC75k • Integration options with other Atlassian products such as JIRA and Confluence
  • 33. BitBucket (continued) 10/22/2013 • On /account/user/<team account>/groups o Set up Administrators, Developers, and Readers groups (Pro Tip: add Team account username to Administrators group by typing full name since it may not appear in auto-search) • On /<account>/<repo>/admin/access (Pro Tip: gear icon in top-right is easy to miss) o Add users and apply appropriate permission (usually “write”) • On /<account>/<repo>/admin/branches o Limit pushes for master to “<account>:administrators“ group o Optionally limit pushes for test and dev o Prevent deletion of master, test, dev branches (Pro Tip: due to BitBucket bug when clicking on textbox initially you may get dropdown, but you must type name not select from dropdown) o Optionally prevent history re-writes (rebase)
  • 34. BitBucket (continued) 10/22/2013 • When ready to move code from dev  test or test  master, use a Pull Request: /<account>/<repo>/pull-request/new
  • 35. Agenda 10/22/2013 • Local  Git config – go beyond user.name and user.email  Start with goal in mind – desired end-state  Workflow – remote repositories, branches, submodules  When things go wrong… • Remote  SSH  BitBucket • Pro Tips & Additional resources
  • 36. Pro Tips 10/22/2013 • After a site is “live”, code only “moves upstream” (dev → test → master), except for TEST bug fixes and PROD hotfixes • After a site is “live”, the database (content) and files only “move downstream” (dev ← test ← master) • Beware any git command including --force DEV PROD
  • 37. Additional Resources 10/22/2013 • “Pro Git” eBook (free): http://git-scm.com/ • Other Git models: • http://svn.haxx.se/users/archive-2007-10/att- 0101/SCMBranchingModels.pdf • http://nvie.com/posts/a-successful-git-branching-model/ • Other Git workflows: https://www.atlassian.com/git/workflows • http://gitignore.io/ • UITS Web & Mobile Services Git documentation (* restricted access, complex, and customized to our environment so email me offline if you want a copy): http://confluence.arizona.edu/display/uitswt/GIT+and+BitBucket+documentation