-
Delivered by Matthew McCullough on 2012-08-31
-
Comox & Courtenay BC, Canada
Git is a version control system you may have been hearing a bit about lately. But simply hearing more about it may not be enough to convince you of its value. Getting hands on experience is what really counts. In this workshop, you'll bring your Windows, Mac or Linux laptop and walk through downloading, installing, and using Git in a collaborative fashion.
The workshop style of this class will allow you to observe and discover the value of this new version control tool first hand. You'll be cloning, creating, commiting, and pushing repositories by the conclusion of this session and will have the public badge of success via pushing a sample repository up to GitHub.
Git is a powerful content tracker and has gained acceptance by many forward leaning consultants and teams over the past several years. Those developers know that it offers the usual commit, branch, merge and tag in a distributed environment, and yet, only a few developers have explored the more powerful functions of Git. These range from searching months of history for a unit-test bug to undoing literally any mistake to splitting in-progress work into multiple commits within a single file.
We'll examine setting up tracking branches with the automatic options, as well as through manual editing of the .git/config file. Next, we'll add multiple remotes and perform a trial merge and rebase of a feature contribution by a team mate. Additionally, we 'll explore the ASCII-art visualizations for branch origins and merge status, repository maintenance, running automated test suites with bisect, submodules and searching for where a constant was introduced in history with git-grep. This workshop will give you prowess in many of the more powerful commands Git has to offer and leave you with a greater mastery of the Git toolset.
This workshop benefits developers who have dabbled with the basics of Git but are aiming to explore, gain productivity secrets, and push the very limits of this life-changing version control system.
- http://githubtraining.s3.amazonaws.com/github-git-training-slides-advanced.pdf
- http://githubtraining.s3.amazonaws.com/github-git-training-slides-teamsandorgs.pdf
- http://githubtraining.s3.amazonaws.com/github-git-training-slides.pdf
- https://speakerdeck.com/u/matthewmccullough/p/the-basics-of-git-and-github
- https://speakerdeck.com/u/matthewmccullough
http://refcardz.dzone.com/refcardz/getting-started-git
https://github.com/githubtraining/git-workshop
http://ambientideas.com/blog/index.php/2010/11/zshell-prompt-for-git/ (which links to the Bash ones)
and the uber-set:
https://github.com/matthewmccullough/scripts
which includes all my OSS work for shell scripts.
As a command line productivity framework, I've become quite attached to oh-my-zsh. It has git-enhanced prompts galore.
https://github.com/robbyrussell/oh-my-zsh
http://delicious.com/matthew.mccullough/git
https://github.com/defunkt/hub
Any follow up Git or GitHub questions can be asked in a desktop-sharing webinar and chat room:
https://github.com/training/free
- Interactive Rebasing
- Traditional squash, reword and edit
- Fixup
- Autosquash
- Controlling pull and push behavior with advanced configuration options.
insteadOf
git config autosetuprebase always
- Changing the refspec directly
- The
+
in the refspec forces the pull or push to overwrite
- Minimizing repetitive merge efforts with
rerere
.git config rerere.enabled true
- Rerere article
- Rerere man page
- Relocating chunks of work with
rebase onto
- Switches branches before rebasing
- Think about moving the "string of beads" onto another endpoint
- Rebase man page
- Git best practices
- Frequent Branching
- Git Flow (too complex)
- GitHub Flow (just right)
- Searching through history with string, combination, and pickaxe approaches.
git log -S "STRING"
git log -G "REGEX"
- Git log man page
- Finding the original author of methods in refactored and relocated code.
git blame -C <FILENAME>
- Git blame man page
- Ways to manage long-term projects
- How GitHub uses Pull Requests
- Patch and Diffs
.patch
and.diff
added to end of commit and Pull Request URLs- https://github.com/githubtraining/hellogitworld/commit/32c273781bab599b955ce7c59d92c39bedf35db0.diff
- https://github.com/githubtraining/hellogitworld/commit/32c273781bab599b955ce7c59d92c39bedf35db0.patch
- Ignoring whitespace
- Cross Repository issue links
- Format:
user/repository#number
- GitHub Flavored Markdown
- Format:
- GitHub Keyboard Shortcuts
- Open github.com and type
?
w
(branch navigator)t
(file navigator)s
(search)m
(markdown cheat sheet)c
(create issue)
- Open github.com and type
- Using the Hub command line tool
- Administratively shaping history with
git filter-branch
- At milestones or after a Subversion import, or when bad data creeps in.
- Examples on how to use filter-branch
- GitHub Help article on filter-branch
- Adding Git notes and their effective namespace use.
touch fix.txt
git add fix.txt
git commit -m"Fixes #1" ; git push
cd try_git.git
mkdir subfolder
cd subfolder
touch largefile.txt
svn add largefile.txt
svn add .
svn add subfolder
svn ci -m "New files"
git clone https://github.com/matthewmccullough/project1 proj1git
git commit -m"Trying this"
git push origin master
svn co https://github.com/matthewmccullough/project1 prj1svn
cd prj1svn
touch svnfile.txt
svn add svnfile.txt
svn ci -m "Subversion"
svn info
svn co https://github.com/matthewmccullough/project1/trunk prj2svn
cd prj2svn
touch newsvnfile.txt
svn add newsvnfile.txt
svn ci -m"Subversion"
cd proj1git
git clone https://github.com/githubstudent/hellogitworld hgwstudent
git branch bugfix
subl .
git commit -m"Bug fix"
subl .git/config
git push -u origin bugfix
git commit -m"CAPS"
git clone git@github.com:githubtrainer/hellogitworld.git hgwtrainer
touch issuefix.txt
git commit -m "Closes #2 by addressing the issue"
history | try_git
history | grep try_git
svn co https://github.com/matthewmccullough/try_git.git
rm -rf try_git.git
svn co https://github.com/matthewmccullough/try_git.git/trunk
cd trunk
touch file.txt
svn add file.txt
svn ci -m "Matthew"
to.courses.repos.git
to.courses.git.repos
cd hellogitworld-bare.git
git clone git@github.com:githubtraining/hellogitworld
touch .travis.yml
vim .travis.yml
mvn test
git add .travis.yml
git commit -m"Travis CI"
git merge FETCH_HEAD --onto master
git reset --hard master FETCH_HEAD
git reset --hard FETCH_HEAD
git rev-parse FETCH_HEAD
vim refs/heads/master
git rev-parse master
git push --mirror
git clone git@github.com:githubtrainer/hellogitworld hgwt
git s
git fetch file://../hellogitworld
cd hgwt
git fetch file:///Users/mccm06/Documents/Temp/Scratch/hellogitworld
git fetch
echo Hello!
git --version
ps -aef | grep git
git add first.html
git add *.txt
git add first.*
git commit -m"My first commit"
git status
mate first.html
git status
git reset --hard
mate first.html
git add .
git commit -m"Mess"
git log
git reset --hard fd4198a7a3fa4472568bc432e374db73511b3fd0
git log
git reflog
git show 76aef41 | mate
to.scratch
git clone https://github.com/githubtraining/hellogitworld
git status
git add .
git status
git commit -m"Importing from old cold system"
mate first.html
git diff
git diff --color-words
git add -p first.html
git status
gitx
git branch feature1
git branch bugfix1
git checkout bugfix
git checkout bugfix1
touch bugfix.txt
git add .
git commit -m"Fixed a bug"
git checkout master
git checkout feature1
mkdir thousandsfeature
cd thousandsfeature
generaterandomfiles 5000 sample txt
git add .
git commit -m"Thousands"
git checkout master
git checkout feature1
cd ..
to.scratch
cd project1
git checkout feature1
git status
vim fix.txt
git add .
git commit -m"Fixed on feature"
cat fix.txt
git checkout master
cat fix.txt
git diff master feature1
git diff master bugfix1
git diff master bugfix1 --color-words
git log master..bugfix1
cd ..
git clone https://github.com/githubstudent/hellogitworld.git hgwstudent
cd hgwstudent
git branch awesomefeature
git checkout awesomefeature
mate src/main/java/com/ambientideas/App.java
git status
git add .
git commit -m"Implemented the feature"
git push -u origin awesomefeature
git add .
git status
git commit -m "Bouncer is awesome"
git push
git checkout master
git add .
git branch designchange
git checkout designchange
git commit -m"Pass 1"
git status
git add .
git commit -m"Paint"
git push -u origin designchange
cd ..
git clone https://github.com/githubtrainer/hellogitworld.git hgwtrainer
cd hgwtrainer
git branch -a
git -remote
git fetch origin refs/pull/1/head
git merge -n FETCH_HEAD
git merge FETCH_HEAD
git status
git log -2
git push
git rm bouncer.png
git commit -m"Removing bouncer. Closes #2"
git push
z git_git
git log
git log --author="Jeremy"
git log --author="Jeremy" --since=2.years.ago
git log --author="Jeremy" --since=4.years.ago
git log --author="Jeremy" --since=4.years.ago -p
git log --author="Jeremy" --since=4.years.ago -p -- Documentation/
git log --author="Jeremy" --since=4.years.ago -S "boolean" -p -- Documentation/
git log --author="Jeremy" --since=4.years.ago -S "boolean" -p --pretty=raw -- Documentation/
git blame rerere.c
git blame -C rerere.c
to.scratch
git svn clone --stdlayout http://ambientideas.unfuddle.com/svn/ambientideas_demo/
cd ambientideas_demo
git status
touch comox.txt
git add .
git commit -m"Matthew was in Comox on 2012-08-31"
git svn dcommit
cd ..
svn co https://github.com/githubstudent/hellogitworld/trunk trunkstudent
cd ..
cd Scratch
z git_git
git log
git log --graph
git log --graph --oneline --abbrev-commit --relative
git log --graph --oneline --abbrev-commit --relative --decorate --simplify-by-decoration
git log --graph --oneline --abbrev-commit --relative --decorate --simplify-by-decoration --before=5.years.ago
cd hellogitworld
git graphlive 25
to.scratch
cd hellogitworld
git checkout bisect
git log
git log --oneline
git bisect start
git bisect good 56cb315
git bisect bad 4478be1
git bisect run mvn test
git bisect reset
cat src/test/java/com/ambientideas/AppTest.java
git status
git log --graph --oneline
git rebase -i 4478be1
git log -3 --graph --oneline
git rebase -i 4478be1
git reflog
git orphank
git config alias.orphank
git checkout master
git merge bisect
git status
git checkout --theirs .gitignore
git checkout --ours pom.xml
git mergetool -t p4merge
git status
rm .gitignore.B*
rm .gitignore.L*
rm .gitignore.R*
git status
git commit
git reset --hard HEAD~1
git reflog
git reset --hard b0a2475
git
cd ..
cp -r hellogitworld hellogitworlddamaged
cd hellogitworlddamaged
git rev-parse HEAD
vim .git/objects/b0/a247570cd6a65aadf1531fb883ecfc6748c574
git status
git fsck
git gc
cd ..
cd hellogitworld
git gc
git log -1
vi .git/refs/heads/handcrafted
git branch
git checkout handcrafted
vi .git/refs/heads/handcrafted
git rev-parse HEAD
git rev-parse HEAD | pbcopy
vi .git/refs/heads/handcrafted
git checkout handcrafted
git status
generaterandomchanges 10 revertme txt
git log
git revert 2351
git show HEAD
git bundle create ../zipme.bundle master