2024: Domino Containers - The Next Step. News from the Domino Container commu...
Introduction to Git
1. Introduction to Git
10/2/2013
Rick Umali
rickumali@gmail.com
@rickumali
http://tech.rickumali.com/
This presentation is on Google Drive at:
http://sn.im/git-talk-2013
There you can read the 'speaker notes' for this
presentation.
2. What is Source Control?
Source code control is the most important
practice a coding professional can do.
A mechanism to track changes in source code.
Used for version history, auditing, and
recovery.
8. Creating a Repository
% cd web/sites/all/modules
% mkdir dumpstamp
% cd dumpstamp
% git init
"git init" creates the entire Git repository.
No server interaction required!
9. Committing Your First File
To 'commit' means 'to save the state' of your
work. You must first 'add' this change to the
'staging area'.
% vi README.txt
% git add README.txt
% git commit -m "First commit. README file."
Commit often!
11. Adding More Files
% vi dumpstamp.info dumpstamp.module
% git status
% git add .
% git commit
or
% git commit -a -m “My commit message.”
Learn the shortcuts by reading Git docs.
12. Examining Changes to Files
% vi dumpstamp.module
% git status
% git diff
% git add dumpstamp.module
% git commit
% git log
Become familiar with Git status and diff
output.
Make your commit messages meaningful!
13. Looking at the Log Again
The history can be examined different ways.
% git log --format=short
% git log --format=oneline
% git log --oneline
14. Revisiting History
You can 'revisit' any point of your history.
% git checkout SHA_ID
Checkout makes the working directory match
the state of the specific SHA_ID.
This is a time machine!
15. Returning to the Present
At all times, Git retains a pointer to the
‘present’.
% git checkout master
16. Branching and Merging Next, But...
What we have covered so far is probably 70-
80% of what you will do with git.
Adding and committing files are the heart of
git (and any version control system).
18. Branching: git branch
% git branch BRANCH
% git checkout BRANCH
This makes a branch from “where you
currently are”, and then “switches” (checks
out) the branch.
“git branch” tells you what branch you’re on.
26. Merging
Bringing two branches together.
First 'checkout' the branch you want to merge
into (typically master), then 'merge' in branch.
% git checkout master
% git merge BRANCH
33. Using Git “Remotely”
You can upload your local Git repository to a
public Git repository. These repositories are
known as remotes.
Using “remotes” is the key to collaborating.
37. Adding a Remote
git remote adds a name for a repo at a
specific URL
git remote add origin git@github.com:rickumali/DumpStamp.
git
Your Repo GitHub Repo
(origin)
Dumpstamp.git
This is just a naming step!
38. Push Your Repo to the Remote
% git push -u origin master
39. Visualizing the Push
git push uploads the repository to the remote
Your Repo GitHub Repo
(origin)
46. Introduction to Git
10/2/2013
Rick Umali
rickumali@gmail.com
@rickumali
http://tech.rickumali.com/
This presentation is on Google Drive at:
http://sn.im/git-talk-2013
There you can read the 'speaker notes' for this
presentation.
47. Resources
http://sethrobertson.github.io/GitBestPractices/
Great list of Git best practices.
http://git-scm.org/
Both "Pro Git" book, and Git reference
http://gitref.org/
A "quicker" Git reference
http://www-cs-students.stanford.edu/~blynn/gitmagic/
"Friendlier" Git walk-through (git magic).
http://www.mail-archive.com/dri-devel@lists.
sourceforge.net/msg39091.html
Linus on "clean history."