Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Git

No description
by

Charles Pham

on 6 November 2013

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Git

devBranch
HEAD
Git Workshop
Instructed by Charles Pham
An introduction to Git
What is Git and why is it useful?
Git is a better solution than the following:
Version control
A software system for tracking and storing many versions and configurations of a single or multiple files
How Git stores its files
Git stores any type of file as the between
each version of a file
Git store multiple versions of the same file
Using for single files (maybe multiple files)
eachother different versions of the same file
Transferring the same file using
Using web services like or to transfer files with no version control
google docs
Emailing
USB flashdrive
dropbox
ftp
does not
differences
How do you use Git?
Your Git Repository
The underlying storage place for all your files
Basic Git Knowledge
How to save your changes?
Save your changes in a
commit
What is a commit?
A commit is a "save point" of your files at a given point in time
What does this mean for you?
You can now have proof of for your group
Allows you to back to a certain version of a file(s)
"what you did"
time travel
(i.e. To go back to a save point where you still had all your lives before you lost them to a boss)
Understanding Basic Git Workflow
How to create your own repository?
The following command will make a repository at your current directory that you are in
git init
How to copy your group's repository?
The following command copies and create a link to your group's repository at your current directory that you are in
git clone <your group's repository url>
Working Directory
This is your playground, its your sandbox with all your changes and cool developmental features
Index and staging
Branch
Basic Git Workflow Commands
Before you can save at a given , you need to tell Git what you want to save, that's called into your
commit
Staging
master
Branching is a way of diverging from your production intent code to develop new features for your program
Index
branch
Think of master branch as the production intent version of your code that builds the program that your consumers view and use
(stable)
(unstable)
git add <file>
Tells git to track a file or change at your next commit
git commit -m "<your comment for the commit>"
Tells git to take a "snapshot" or save your current work
git checkout <branch name>
git rm <file>
Tells git to stop tracking a file or change at your next commit and onwards
Tells git you want to jump to another save point to work on another version of your set of code
git status
Asks git whats happening in your working directory and whats going into your next commit
git diff <commit/branch>
Asks git what is the differences between your current files and a specific previous commit
Simple Git Workflow Examples
git init
This is your new git repository
Creating a git repository
0th commit
Once you use the command, you create a brand new git repository which is empty.
git clone <your group's git repository>
Copying a git repository
HEAD
This is a special handle to get a hold of your current commit
Simple Repository
HEAD
Older commits from your group's repository
Index
Newest commit
Copies your group's repository onto your computer
Saves ALL their links, commits, branches, and files onto your computer
master
Index
2nd and newest commit
0th commit
1st commit
HEAD
This is a special handle to get a hold of your current save point
your production intent branch (latest most stable code)
master
Index
is where you tell git what files you want to save in your next commit
Steps to commit
Index
Working Directory
file.c
file.h
a.txt
b.png
git add file.c file.h
file.c
file.h
git commit
HEAD
HEAD
file.c
file.h
git merge <other branch>
Tells git to merge all the changes from the <other branch> to your current branch that you are on
git reset HEAD <file>
Tells git to ignore a file or change that is currently about to be saved at your next commit
Creating a branch
master
HEAD
git checkout -b "devBranch"
HEAD
devBranch
These two commits have identical changes at the instance you create the branch
git rebase <other branch> <your current branch>
Tells git to put your changes on top of all the other changes from other branch and relink accordingly
git log
Asks git to list all the save points in your current branch
Merging two branches
master
HEAD
git merge master devBranch
devBranch
master
HEAD
1) devBranch was branched from master awhile ago;
2) master then made some changes;
3) lets say devBranch made new features and is now ready to merge back into master
Hosted by Society of Computer Engineering
Rebasing one branch with another branch
master
git rebase master devBranch
1) devBranch was branched from master awhile ago;
2) master then made some changes;
3) lets say devBranch made new features but is not ready to be merged into master; however we dont want to be behind master too much so we rebase
HEAD
devBranch
Until now, everything we talked about was locally done on your computer
Lets talk git servers
Git Server Hosts
bitbucket
What does it mean to have your git repository hosted on a server?
Generally the git server can be viewed as:
secondary online backup/storage
a means to collaborate and share code/files with other people who have access to the server git repository
Copying a repository
master
REMOTE
Lets say I host this remote git repository on bitbucket.org and the repository has name "myRepo"
git clone git@bitbucket.org/username/myRepo
master
LOCAL
HEAD
github
Interacting with a server repository
master
REMOTE
master
LOCAL
HEAD
git pull origin master
When a pull command is initiated, your local git
all the changes that are different from your local git repository and the server repository; then the changes from server repository into your local repository
fetches
merges
master
HEAD
Interacting with a server repository
LOCAL
master
REMOTE
git push origin master
When a push command is initiated, your local git
all the changes that are different from your local git repository and the server repository; then the changes from your local repository into server repository
pushes
merges
master
master
HEAD
Basic Git Server Interaction Commands
git push <to remote branch/origin> <from local branch>
Tells local git to update server git of all local git's new information/changes
git pull <from remote branch/origin> <to local branch>
Tells local git to ask server git if anything has changed in server using git fetch; then merge any new information/changes from server into local git
git fetch
Asks local git to talk to server git to figure out if any changes on the server has occurred; if so, local git then updates its knowledge to know about the changes but does not make those server changes locally.
Useful Git Knowledge
When in doubt "man <command>" or "git <command> --help" it
git config --global user.name "<your first and last name>"
git config --global user.email "<your email>"
git config --global color.ui true
Learn basic commands of VIM
When all else fails, google it
Git Hands-on Demonstration
Full transcript