SlideShare une entreprise Scribd logo
1  sur  14
Télécharger pour lire hors ligne
@eneldoserrata
My Notes from
https://www.codeschool.com/
courses/git-real
https://www.codeschool.com/courses/git-real Page of1 14
@eneldoserrata 1
My Notes from 1
https://www.codeschool.com/courses/git-real 1
GIT REAL I 5
LEVEL 1: INTRODUCTION 5__________________________________
HELP ON COMMAND: 5...........................................................................................
WHO ARE YOU?: 5...................................................................................................
START REPO: 5........................................................................................................
WHAT'S MODIFIED?: 5.............................................................................................
STAGE FILES: 5........................................................................................................
COMMIT FILES: 5.....................................................................................................
STAGE MANY FILES: 5.............................................................................................
SHOW COMMITS: 6..................................................................................................
LEVEL 2: STAGING & REMOTES 6_____________________________
UNSTAGED DIFFERENCES 6..................................................................................
STAGE NEW FILE 6..................................................................................................
STAGED DIFFERENCES 6.......................................................................................
UNSTAGE FILES 6....................................................................................................
SKIP STAGING 6.......................................................................................................
ADD TO COMMIT I 6.................................................................................................
ADD TO COMMIT II 7................................................................................................
ROLL BACK COMMIT 7............................................................................................
DISCARD CHANGES 7.............................................................................................
REMOVE COMMIT I 7...............................................................................................
REMOVE COMMIT II 7..............................................................................................
NEW REMOTE REPOS 7.........................................................................................
PUSH TO A REMOTE 7.............................................................................................
LEVEL 3: CLONING & BRANCHING 8___________________________
CLONE A REPO 8.....................................................................................................
LIST REMOTES 8.....................................................................................................
CREATE A BRANCH 8..............................................................................................
SWITCH TO BRANCH 8............................................................................................
COMBINE BRANCH I 8.............................................................................................
COMBINE BRANCH II 8............................................................................................
BRANCH SHORTCUT 8............................................................................................
https://www.codeschool.com/courses/git-real Page of2 14
LEVEL 4: COLLABORATION BASICS 9__________________________
SEND CHANGES 9...................................................................................................
GET CHANGES 9......................................................................................................
FIX CONFLICTS 9.....................................................................................................
MARK FIXED 10........................................................................................................
COMMIT FIX 10.........................................................................................................
LEVEL 5: BRANCHING 10____________________________________
PUSH BRANCH 10....................................................................................................
GET REMOTE BRANCH 10......................................................................................
REMOTE BRANCHES 10.........................................................................................
DELETE ON REMOTE 10.........................................................................................
BRANCH STATUS 10................................................................................................
CLEAN BRANCHES 10.............................................................................................
LIST TAGS 11............................................................................................................
CREATE TAG 11........................................................................................................
SEND TAGS 11..........................................................................................................
RETRIEVE TAG 11....................................................................................................
LEVEL 6: REBASE BELONG TO US 11__________________________
REBASE I 11.............................................................................................................
REBASE II 11............................................................................................................
REBASE III 11...........................................................................................................
REBASE IV 12...........................................................................................................
REMOTE I 12............................................................................................................
REMOTE II 12...........................................................................................................
CONFLICT I 12..........................................................................................................
CONFLICT II 12.........................................................................................................
CONFLICT III 12........................................................................................................
CONFLICT IV 13.......................................................................................................
CONFLICT V 13........................................................................................................
LEVEL 7: HISTORY AND CONFIGURATION 13___________________
SHORT HISTORY 13................................................................................................
SHOW CHANGES 13................................................................................................
BRANCH CHANGES 13............................................................................................
ANCESTOR COMMITS 13........................................................................................
HISTORY WITH DIFF 13...........................................................................................
WHOSE LINE IS IT? 13.............................................................................................
https://www.codeschool.com/courses/git-real Page of3 14
IGNORE FILES 14.....................................................................................................
CONFIGURATION 14................................................................................................
GLOBAL CONFIG 14.................................................................................................
ALIAS 14....................................................................................................................
https://www.codeschool.com/courses/git-real Page of4 14
GIT REAL I
LEVEL 1: INTRODUCTION
HELP ON COMMAND:
You can't quite recall what parameters the config command takes, though. Run the git command
which will bring up the help page for config.
$ git help config
WHO ARE YOU?:
Before you start working with Git, you need to set up your name to include with commit messages.
Use git config to set your user name (could be anything), across all repos on this machine.
$ git config --global user.name "Your Name Here”
START REPO:
You've begun working on the project, so it's time to setup version control. Set up a new Git repo
within the current directory.
$ git init
WHAT'S MODIFIED?:
Okay, you've created a couple files but you can't remember which needed committing. Use the Git
command which will show the state of your files.
$ git status
STAGE FILES:
Ah, there's your file. It's never been committed before, so add it to the staging area.
$ git add index.html
COMMIT FILES:
Now add your staged changes to the Git repo by committing them.
$ git commit -m "Insert commit message here.”
STAGE MANY FILES:
You've made a subdirectory for stylesheets, but nothing's committed yet. Add all files in the css/
directory to the stage.
https://www.codeschool.com/courses/git-real Page of5 14
$ git add css/
SHOW COMMITS:
Your co-worker stops by, and asks what you've gotten committed. Bring up the commit history to
show him.
$ git log
LEVEL 2: STAGING & REMOTES
UNSTAGED DIFFERENCES
A new file has been added to the site. Run the command to see what all has changed since your
last commit.
$ git diff
STAGE NEW FILE
There it is: ostrich.html. Stage it to be committed.
$ git add ostrich.html
STAGED DIFFERENCES
We've added ostrich.html to the staging area, but your co-worker has stopped by and asked to see
the new page first. Run a diff on the staged changes.
$ git diff —staged
UNSTAGE FILES
"Wait," says the co-worker. "They didn't tell you? The client "wants the ostrich section pulled - they
couldn't get a license to "sell them." Better unstage ostrich.html.
$ git reset HEAD ostrich.html
SKIP STAGING
We've modified the index.html file, adding a link to the cats section. Since that file is already
tracked, you can just skip staging and commit it with one command.
$ git commit -a -m "Any message.”
ADD TO COMMIT I
Whoops! We forgot to add the cats.html page that index.html links to, and it should really be
amended on the same commit. To do this, let's first stage cats.html.
https://www.codeschool.com/courses/git-real Page of6 14
$ git add cats.html
ADD TO COMMIT II
Second, let's add cats.html to the prior commit and change the commit message in one step.
$ git commit --amend -m "I forgot this file”
ROLL BACK COMMIT
Wait, you're getting word that the cats section might be cancelled. Undo the commit, and put the
files back in staging.
$ git reset --soft HEAD^
DISCARD CHANGES
Forget the whole thing - the client's license to sell cats is suspended during some kind of
"investigation". Discard your changes to cats.html and index.html.
$ git checkout -- cats.html index.html
REMOVE COMMIT I
The next feature is a banner on the main page, saying the pet shop will soon be offering badgers.
Add and commit index.html in one step, skipping the staging area.
$ git commit -a -m "Any message”
REMOVE COMMIT II
Your co-worker is back, looking sheepish. "Never mind the badgers ad. The client's legal
department said that was a liability risk." You'll need to remove the most recent commit, and all its
changes.
$ git reset --hard HEAD^
NEW REMOTE REPOS
Oh well, at least you have the site started. Your Example Labs co-worker got you the remote
address for the shared repo: git@example.com:example/petshop.git. Add that address as the
origin repo.
$ git remote add origin git@example.com:example/petshop.git
PUSH TO A REMOTE
Done for the day! Send your committed work to "origin". Make sure you use the -u option so origin
will be the default destination in the future.
https://www.codeschool.com/courses/git-real Page of7 14
$ git push -u origin master
LEVEL 3: CLONING & BRANCHING
CLONE A REPO
The IT department installed an OS update on your workstation - and wiped the hard drive in the
process. Clone the Pet Shop repo from git@example.com:example/petshop.git so you can resume
work.
$ git clone git@example.com:example/petshop.git
LIST REMOTES
Our repo is cloned locally, but how do we check to a list of our remotes? Lets get a list of all our
remotes with a verbose output.
$ git remote -v
CREATE A BRANCH
We need to add a section for the pet grooming salon on the site. You want to isolate this new
feature from your other work. Create a new branch named grooming.
$ git branch grooming
SWITCH TO BRANCH
You've made the new branch, but your commits are still going to the old one. Switch to the
grooming branch.
$ git checkout grooming
COMBINE BRANCH I
You've finished work on the grooming branch and are ready to bring your work back into master.
First, check out the master branch…
$ git checkout master
COMBINE BRANCH II
...Now bring your changes from the grooming branch into the ...master branch.
$ git merge grooming
BRANCH SHORTCUT
The pet shop wants to try selling yet another product line! Let's do this one in a branch in case it
gets cancelled like the others. Using a single command, create and check out an octopus branch.
https://www.codeschool.com/courses/git-real Page of8 14
$ git checkout -b octopus
LEVEL 4: COLLABORATION BASICS
SEND CHANGES
You've committed some work so now it's time to share! Push it out for your co-workers to see.
$ git push
GET CHANGES
Looks like your co-worker pushed some changes before you did! Your push was rejected. Retrieve
the latest changes, and merge them into your branch in one step.
$ git pull
FIX CONFLICTS
Git is reporting a conflict with your co-worker's changes in "index.html". Just discard his changes,
and keep your own (the HEAD).
Problem:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Our Cat-alog</title>
</head>
<body>
<nav>
<ul>
<<<<<<< HEAD
<li><a href="cat.html">Cats</a></li>
<li><a href="dog.html">Dogs</a></li>
=======
<li><a href="cat.html">Felines</a></li>
<li><a href="dog.html">Canines</a></li>
>>>>>>> 6a487f9eb0e0a5110bdf2a45a4f5dbcc3d4eec53
</ul>
</nav>
</body>
</html>
Solution:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Our Cat-alog</title>
</head>
<body>
<nav>
<ul>
<li><a href="cat.html">Cats</a></li>
<li><a href="dog.html">Dogs</a></li>
</ul>
</nav>
</body>
</html>
https://www.codeschool.com/courses/git-real Page of9 14
MARK FIXED
Mark the conflict in index.html as resolved.
$ git add index.html
COMMIT FIX
Last, commit your merged changes. Don't forget to add a message so we know what the commit
was about!
$ git commit -m “Change fix”
LEVEL 5: BRANCHING
PUSH BRANCH
A new kind of pet is for sale at the store! Maybe this one will catch on with the public. You've
committed your work to the local hamsters branch; now publish this branch in the origin repo.
$ git push origin hamsters
GET REMOTE BRANCH
"git branch -r" does not query the remotes to check for new branches. In order to see a new remote
branch you first have to do a fetch or a pull. So retrieve the remote "weasel" branch.
$ git fetch
REMOTE BRANCHES
Your co-worker said he wants you to look over a new branch on "origin", but he didn't tell you its
name. Get a list of remote branches.
$ git remote show origin
DELETE ON REMOTE
Guess how the product launch went with the weasels? Better delete the "weasel" branch on
“origin".
$ git push origin :weasel
BRANCH STATUS
Wait, did you already pull that branch locally? Check for stale branches that are tracking “origin".
$ git remote show origin
CLEAN BRANCHES
https://www.codeschool.com/courses/git-real Page of10 14
You still have a stale local branch tracking the now-deleted origin/weasel. Clean up your local
references.
$ git remote prune origin
LIST TAGS
With the weasel threat eliminated, the pet store wants to deploy the site. Let's see, what was the
previous version number? Display the tags to find out.
$ git tag
CREATE TAG
Ah, yes, the last release was "v1.3.1". You've added the hamsters, so it would be best to release
this as "v1.3.2". Create a tag accordingly.
$ git tag -a v1.3.2 -m "Version 1.3.2”
SEND TAGS
Push your tag to origin.
$ git push —tags
RETRIEVE TAG
The client is requesting that you roll back to the prior release. (Seriously? What could have gone
wrong with the hamsters?) Retrieve the release tagged “v1.3.1".
git checkout v1.3.1
LEVEL 6: REBASE BELONG TO US
REBASE I
You've made some commits to a feature branch, but you've also committed a hotfix on master that
would make a merge messy. Check out the kennel branch so you can rebase it on master.
$ git checkout kennel
REBASE II
OK, you're on the kennel branch. Our goal is to be able to merge kennel back into master without
conflicts or a merge commit. Rebase the current kennel branch on master.
$ git rebase master
REBASE III
$ git checkout master
https://www.codeschool.com/courses/git-real Page of11 14
REBASE IV
We're on master, and we know the kennel will merge cleanly. Go ahead and merge in the kennel
branch.
$ git merge kennel
REMOTE I
Your co-worker has pushed changes to the master branch on the origin repo. Retrieve it without
merging it so we can replay our work on top of it.
$ git fetch
REMOTE II
Now that your local repo knows of the latest changes on origin/master, move your master commits
after the commits from origin/master.
$ git rebase
CONFLICT I
Your co-worker has pushed before you yet again. Better fetch the changes…
$ git fetch
CONFLICT II
Now run another rebase to move your commit after the latest fetched one.
$ git rebase
CONFLICT III
Uh, oh! Looks like the rebase is in conflict this time! Edit index.html to fix the conflicting lines. We
want to keep our version with Cats and Dogs.
Problem:
<nav>
<ul>
<<<<<<< HEAD
<li><a href="cat.html">Cats</a></li>
<li><a href="dog.html">Dogs</a></li>
=======
<li><a href="cat.html">Felines</a></li>
<li><a href="dog.html">Canines</a></li>
>>>>>>> Add dogs.
</ul>
</nav>
Solution:
<nav>
<ul>
<li><a href="cat.html">Cats</a></li>
<li><a href="dog.html">Dogs</a></li>
</ul>
</nav>
https://www.codeschool.com/courses/git-real Page of12 14
CONFLICT IV
Now mark the conflicts in "index.html" as resolved.
$ git add index.html
CONFLICT V
Now that all conflicts have been resolved and those files added, continue the current rebase in
process.
$ git rebase —continue
LEVEL 7: HISTORY AND CONFIGURATION
SHORT HISTORY
All those e-mail addresses and SHAs are making it hard to see commit messages in your history.
Try viewing the log with one commit per line.
$ git log —pretty=oneline
SHOW CHANGES
The client called with an urgent question about chew toys, and now you can't remember what you
last modified. Bring up a summary of file changes.
$ git diff
BRANCH CHANGES
You've finished adding elephants to the catalog. You need to write up a change log for the client,
and you want to ensure you don't miss anything. Compare the master branch to your elephant
branch to show what's new.
$ git diff master elephant
ANCESTOR COMMITS
You rebased your latest commit after a commit from your co-worker, but now the page is rendering
strangely. To figure out why, get a diff that includes the previous commit, as well as its parent.
$ git diff HEAD^^
HISTORY WITH DIFF
$ git log —patch
WHOSE LINE IS IT?
Wait, what? You don't understand these lines in index.html. You'd better find out who committed
them, so you can ask them what they're supposed to do.
https://www.codeschool.com/courses/git-real Page of13 14
$ git blame index.html
IGNORE FILES
Your server writes files to the logs directory. You're not going to commit them, but they keep
appearing in your git status output, and you'd like them not to. Edit your .gitignore file to ignore all
files in the logs/ directory whose names end in .log.
#Enter text here
logs/*.log
CONFIGURATION
Just for this repo, set the user.email value to admin@example.com.
$ git config user.email admin@example.com
GLOBAL CONFIG
Set your name as the user.name value for all Git repos.
$ git config --global user.name "Michael Jackson”
ALIAS
commit just won't suffice for your code. You need a command that conveys the importance of the
work that you're entrusting to Git. Alias git commit to git beholdmyamazingcode (or something
equally awesome).
$ git config --global alias.beholdmyamazingcode commit
https://www.codeschool.com/courses/git-real Page of14 14

Contenu connexe

Tendances

The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitE Carter
 
Git Basics - RubyFest 2009
Git Basics - RubyFest 2009Git Basics - RubyFest 2009
Git Basics - RubyFest 2009Ariejan de Vroom
 
Git Basics (Professionals)
 Git Basics (Professionals) Git Basics (Professionals)
Git Basics (Professionals)bryanbibat
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of GitDivineOmega
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshopthemystic_ca
 
Recovering From Git Mistakes - Nina Zakharenko
Recovering From Git Mistakes - Nina ZakharenkoRecovering From Git Mistakes - Nina Zakharenko
Recovering From Git Mistakes - Nina ZakharenkoNina Zakharenko
 
Github - Le Wagon Melbourne
Github - Le Wagon MelbourneGithub - Le Wagon Melbourne
Github - Le Wagon MelbournePaal Ringstad
 
Git Version Control System
Git Version Control SystemGit Version Control System
Git Version Control SystemKMS Technology
 
Git: basic to advanced
Git: basic to advancedGit: basic to advanced
Git: basic to advancedYodalee
 
Version control system
Version control systemVersion control system
Version control systemAndrew Liu
 

Tendances (20)

The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 
Git Basics - RubyFest 2009
Git Basics - RubyFest 2009Git Basics - RubyFest 2009
Git Basics - RubyFest 2009
 
Working with Git
Working with GitWorking with Git
Working with Git
 
Git & GitHub for Beginners
Git & GitHub for BeginnersGit & GitHub for Beginners
Git & GitHub for Beginners
 
Git Basics (Professionals)
 Git Basics (Professionals) Git Basics (Professionals)
Git Basics (Professionals)
 
Git advanced
Git advancedGit advanced
Git advanced
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of Git
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
Recovering From Git Mistakes - Nina Zakharenko
Recovering From Git Mistakes - Nina ZakharenkoRecovering From Git Mistakes - Nina Zakharenko
Recovering From Git Mistakes - Nina Zakharenko
 
Github
GithubGithub
Github
 
Github - Le Wagon Melbourne
Github - Le Wagon MelbourneGithub - Le Wagon Melbourne
Github - Le Wagon Melbourne
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 
git and github
git and githubgit and github
git and github
 
Git github
Git githubGit github
Git github
 
Git Version Control System
Git Version Control SystemGit Version Control System
Git Version Control System
 
GIT_In_90_Minutes
GIT_In_90_MinutesGIT_In_90_Minutes
GIT_In_90_Minutes
 
Git: basic to advanced
Git: basic to advancedGit: basic to advanced
Git: basic to advanced
 
Git for the absolute beginners
Git for the absolute beginnersGit for the absolute beginners
Git for the absolute beginners
 
Git Basic
Git BasicGit Basic
Git Basic
 
Version control system
Version control systemVersion control system
Version control system
 

Similaire à My Notes from https://www.codeschool.com/courses/git-real

Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for ArtistsDavid Newbury
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control SystemVictor Wong
 
GIT training - advanced for software projects
GIT training - advanced for software projectsGIT training - advanced for software projects
GIT training - advanced for software projectsThierry Gayet
 
Git in pills : git stash
Git in pills : git stashGit in pills : git stash
Git in pills : git stashFederico Panini
 
Introduction to git and Github
Introduction to git and GithubIntroduction to git and Github
Introduction to git and GithubWycliff1
 
Using Git on the Command Line
Using Git on the Command LineUsing Git on the Command Line
Using Git on the Command LineBrian Richards
 
Git as version control for Analytics project
Git as version control for Analytics projectGit as version control for Analytics project
Git as version control for Analytics projectNag Arvind Gudiseva
 
2015-ghci-presentation-git_gerritJenkins_final
2015-ghci-presentation-git_gerritJenkins_final2015-ghci-presentation-git_gerritJenkins_final
2015-ghci-presentation-git_gerritJenkins_finalMythri P K
 
Git lord | A brief intro about git commands in Star Wars theme
Git lord | A brief intro about git commands in Star Wars themeGit lord | A brief intro about git commands in Star Wars theme
Git lord | A brief intro about git commands in Star Wars themeAkarsh Satija
 
Openstack contribution process
Openstack contribution processOpenstack contribution process
Openstack contribution processSyed Armani
 
OpenStack Contribution Process
OpenStack Contribution ProcessOpenStack Contribution Process
OpenStack Contribution Processopenstackindia
 
Gerrit Code Review: how to script a plugin with Scala and Groovy
Gerrit Code Review: how to script a plugin with Scala and GroovyGerrit Code Review: how to script a plugin with Scala and Groovy
Gerrit Code Review: how to script a plugin with Scala and GroovyLuca Milanesio
 
introductiontogitandgithub-120702044048-phpapp01.pdf
introductiontogitandgithub-120702044048-phpapp01.pdfintroductiontogitandgithub-120702044048-phpapp01.pdf
introductiontogitandgithub-120702044048-phpapp01.pdfBruceLee275640
 
Managing releases effectively through git
Managing releases effectively through gitManaging releases effectively through git
Managing releases effectively through gitMohd Farid
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow Sebin Benjamin
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git聖文 鄭
 

Similaire à My Notes from https://www.codeschool.com/courses/git-real (20)

Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
GIT training - advanced for software projects
GIT training - advanced for software projectsGIT training - advanced for software projects
GIT training - advanced for software projects
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
 
Git in pills : git stash
Git in pills : git stashGit in pills : git stash
Git in pills : git stash
 
Git guide
Git guideGit guide
Git guide
 
Introduction to git and Github
Introduction to git and GithubIntroduction to git and Github
Introduction to git and Github
 
Gerrit tutorial
Gerrit tutorialGerrit tutorial
Gerrit tutorial
 
Using Git on the Command Line
Using Git on the Command LineUsing Git on the Command Line
Using Git on the Command Line
 
Git as version control for Analytics project
Git as version control for Analytics projectGit as version control for Analytics project
Git as version control for Analytics project
 
2015-ghci-presentation-git_gerritJenkins_final
2015-ghci-presentation-git_gerritJenkins_final2015-ghci-presentation-git_gerritJenkins_final
2015-ghci-presentation-git_gerritJenkins_final
 
Git
GitGit
Git
 
Git lord | A brief intro about git commands in Star Wars theme
Git lord | A brief intro about git commands in Star Wars themeGit lord | A brief intro about git commands in Star Wars theme
Git lord | A brief intro about git commands in Star Wars theme
 
Openstack contribution process
Openstack contribution processOpenstack contribution process
Openstack contribution process
 
OpenStack Contribution Process
OpenStack Contribution ProcessOpenStack Contribution Process
OpenStack Contribution Process
 
Gerrit Code Review: how to script a plugin with Scala and Groovy
Gerrit Code Review: how to script a plugin with Scala and GroovyGerrit Code Review: how to script a plugin with Scala and Groovy
Gerrit Code Review: how to script a plugin with Scala and Groovy
 
introductiontogitandgithub-120702044048-phpapp01.pdf
introductiontogitandgithub-120702044048-phpapp01.pdfintroductiontogitandgithub-120702044048-phpapp01.pdf
introductiontogitandgithub-120702044048-phpapp01.pdf
 
Managing releases effectively through git
Managing releases effectively through gitManaging releases effectively through git
Managing releases effectively through git
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
 

Plus de Eneldo Serrata

Cooperacion cnc promipyme-asonaimco
Cooperacion cnc promipyme-asonaimcoCooperacion cnc promipyme-asonaimco
Cooperacion cnc promipyme-asonaimcoEneldo Serrata
 
Contrato asonaimco compromiso especifico
Contrato asonaimco compromiso especificoContrato asonaimco compromiso especifico
Contrato asonaimco compromiso especificoEneldo Serrata
 
Contrato fondec no 20 2014
Contrato fondec no 20 2014Contrato fondec no 20 2014
Contrato fondec no 20 2014Eneldo Serrata
 
Acuerdo colaboración interinstitucional asonaimco
Acuerdo colaboración interinstitucional asonaimcoAcuerdo colaboración interinstitucional asonaimco
Acuerdo colaboración interinstitucional asonaimcoEneldo Serrata
 
Administración de la interfaz en su versión 7
Administración de la interfaz en su versión 7Administración de la interfaz en su versión 7
Administración de la interfaz en su versión 7Eneldo Serrata
 
Descripción de la interfaz de programación
Descripción de la interfaz de programaciónDescripción de la interfaz de programación
Descripción de la interfaz de programaciónEneldo Serrata
 

Plus de Eneldo Serrata (12)

MarkAD
MarkADMarkAD
MarkAD
 
Odoo a simple vista
Odoo a simple vistaOdoo a simple vista
Odoo a simple vista
 
Cooperacion cnc promipyme-asonaimco
Cooperacion cnc promipyme-asonaimcoCooperacion cnc promipyme-asonaimco
Cooperacion cnc promipyme-asonaimco
 
Contrato asonaimco compromiso especifico
Contrato asonaimco compromiso especificoContrato asonaimco compromiso especifico
Contrato asonaimco compromiso especifico
 
Contrato fondec no 20 2014
Contrato fondec no 20 2014Contrato fondec no 20 2014
Contrato fondec no 20 2014
 
Acuerdo colaboración interinstitucional asonaimco
Acuerdo colaboración interinstitucional asonaimcoAcuerdo colaboración interinstitucional asonaimco
Acuerdo colaboración interinstitucional asonaimco
 
Mayo 2007
Mayo 2007Mayo 2007
Mayo 2007
 
Enero 2007
Enero 2007Enero 2007
Enero 2007
 
Noviembre 2006
Noviembre 2006Noviembre 2006
Noviembre 2006
 
Estatutos asonaimco
Estatutos asonaimcoEstatutos asonaimco
Estatutos asonaimco
 
Administración de la interfaz en su versión 7
Administración de la interfaz en su versión 7Administración de la interfaz en su versión 7
Administración de la interfaz en su versión 7
 
Descripción de la interfaz de programación
Descripción de la interfaz de programaciónDescripción de la interfaz de programación
Descripción de la interfaz de programación
 

Dernier

Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Dernier (20)

Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

My Notes from https://www.codeschool.com/courses/git-real

  • 2. @eneldoserrata 1 My Notes from 1 https://www.codeschool.com/courses/git-real 1 GIT REAL I 5 LEVEL 1: INTRODUCTION 5__________________________________ HELP ON COMMAND: 5........................................................................................... WHO ARE YOU?: 5................................................................................................... START REPO: 5........................................................................................................ WHAT'S MODIFIED?: 5............................................................................................. STAGE FILES: 5........................................................................................................ COMMIT FILES: 5..................................................................................................... STAGE MANY FILES: 5............................................................................................. SHOW COMMITS: 6.................................................................................................. LEVEL 2: STAGING & REMOTES 6_____________________________ UNSTAGED DIFFERENCES 6.................................................................................. STAGE NEW FILE 6.................................................................................................. STAGED DIFFERENCES 6....................................................................................... UNSTAGE FILES 6.................................................................................................... SKIP STAGING 6....................................................................................................... ADD TO COMMIT I 6................................................................................................. ADD TO COMMIT II 7................................................................................................ ROLL BACK COMMIT 7............................................................................................ DISCARD CHANGES 7............................................................................................. REMOVE COMMIT I 7............................................................................................... REMOVE COMMIT II 7.............................................................................................. NEW REMOTE REPOS 7......................................................................................... PUSH TO A REMOTE 7............................................................................................. LEVEL 3: CLONING & BRANCHING 8___________________________ CLONE A REPO 8..................................................................................................... LIST REMOTES 8..................................................................................................... CREATE A BRANCH 8.............................................................................................. SWITCH TO BRANCH 8............................................................................................ COMBINE BRANCH I 8............................................................................................. COMBINE BRANCH II 8............................................................................................ BRANCH SHORTCUT 8............................................................................................ https://www.codeschool.com/courses/git-real Page of2 14
  • 3. LEVEL 4: COLLABORATION BASICS 9__________________________ SEND CHANGES 9................................................................................................... GET CHANGES 9...................................................................................................... FIX CONFLICTS 9..................................................................................................... MARK FIXED 10........................................................................................................ COMMIT FIX 10......................................................................................................... LEVEL 5: BRANCHING 10____________________________________ PUSH BRANCH 10.................................................................................................... GET REMOTE BRANCH 10...................................................................................... REMOTE BRANCHES 10......................................................................................... DELETE ON REMOTE 10......................................................................................... BRANCH STATUS 10................................................................................................ CLEAN BRANCHES 10............................................................................................. LIST TAGS 11............................................................................................................ CREATE TAG 11........................................................................................................ SEND TAGS 11.......................................................................................................... RETRIEVE TAG 11.................................................................................................... LEVEL 6: REBASE BELONG TO US 11__________________________ REBASE I 11............................................................................................................. REBASE II 11............................................................................................................ REBASE III 11........................................................................................................... REBASE IV 12........................................................................................................... REMOTE I 12............................................................................................................ REMOTE II 12........................................................................................................... CONFLICT I 12.......................................................................................................... CONFLICT II 12......................................................................................................... CONFLICT III 12........................................................................................................ CONFLICT IV 13....................................................................................................... CONFLICT V 13........................................................................................................ LEVEL 7: HISTORY AND CONFIGURATION 13___________________ SHORT HISTORY 13................................................................................................ SHOW CHANGES 13................................................................................................ BRANCH CHANGES 13............................................................................................ ANCESTOR COMMITS 13........................................................................................ HISTORY WITH DIFF 13........................................................................................... WHOSE LINE IS IT? 13............................................................................................. https://www.codeschool.com/courses/git-real Page of3 14
  • 4. IGNORE FILES 14..................................................................................................... CONFIGURATION 14................................................................................................ GLOBAL CONFIG 14................................................................................................. ALIAS 14.................................................................................................................... https://www.codeschool.com/courses/git-real Page of4 14
  • 5. GIT REAL I LEVEL 1: INTRODUCTION HELP ON COMMAND: You can't quite recall what parameters the config command takes, though. Run the git command which will bring up the help page for config. $ git help config WHO ARE YOU?: Before you start working with Git, you need to set up your name to include with commit messages. Use git config to set your user name (could be anything), across all repos on this machine. $ git config --global user.name "Your Name Here” START REPO: You've begun working on the project, so it's time to setup version control. Set up a new Git repo within the current directory. $ git init WHAT'S MODIFIED?: Okay, you've created a couple files but you can't remember which needed committing. Use the Git command which will show the state of your files. $ git status STAGE FILES: Ah, there's your file. It's never been committed before, so add it to the staging area. $ git add index.html COMMIT FILES: Now add your staged changes to the Git repo by committing them. $ git commit -m "Insert commit message here.” STAGE MANY FILES: You've made a subdirectory for stylesheets, but nothing's committed yet. Add all files in the css/ directory to the stage. https://www.codeschool.com/courses/git-real Page of5 14
  • 6. $ git add css/ SHOW COMMITS: Your co-worker stops by, and asks what you've gotten committed. Bring up the commit history to show him. $ git log LEVEL 2: STAGING & REMOTES UNSTAGED DIFFERENCES A new file has been added to the site. Run the command to see what all has changed since your last commit. $ git diff STAGE NEW FILE There it is: ostrich.html. Stage it to be committed. $ git add ostrich.html STAGED DIFFERENCES We've added ostrich.html to the staging area, but your co-worker has stopped by and asked to see the new page first. Run a diff on the staged changes. $ git diff —staged UNSTAGE FILES "Wait," says the co-worker. "They didn't tell you? The client "wants the ostrich section pulled - they couldn't get a license to "sell them." Better unstage ostrich.html. $ git reset HEAD ostrich.html SKIP STAGING We've modified the index.html file, adding a link to the cats section. Since that file is already tracked, you can just skip staging and commit it with one command. $ git commit -a -m "Any message.” ADD TO COMMIT I Whoops! We forgot to add the cats.html page that index.html links to, and it should really be amended on the same commit. To do this, let's first stage cats.html. https://www.codeschool.com/courses/git-real Page of6 14
  • 7. $ git add cats.html ADD TO COMMIT II Second, let's add cats.html to the prior commit and change the commit message in one step. $ git commit --amend -m "I forgot this file” ROLL BACK COMMIT Wait, you're getting word that the cats section might be cancelled. Undo the commit, and put the files back in staging. $ git reset --soft HEAD^ DISCARD CHANGES Forget the whole thing - the client's license to sell cats is suspended during some kind of "investigation". Discard your changes to cats.html and index.html. $ git checkout -- cats.html index.html REMOVE COMMIT I The next feature is a banner on the main page, saying the pet shop will soon be offering badgers. Add and commit index.html in one step, skipping the staging area. $ git commit -a -m "Any message” REMOVE COMMIT II Your co-worker is back, looking sheepish. "Never mind the badgers ad. The client's legal department said that was a liability risk." You'll need to remove the most recent commit, and all its changes. $ git reset --hard HEAD^ NEW REMOTE REPOS Oh well, at least you have the site started. Your Example Labs co-worker got you the remote address for the shared repo: git@example.com:example/petshop.git. Add that address as the origin repo. $ git remote add origin git@example.com:example/petshop.git PUSH TO A REMOTE Done for the day! Send your committed work to "origin". Make sure you use the -u option so origin will be the default destination in the future. https://www.codeschool.com/courses/git-real Page of7 14
  • 8. $ git push -u origin master LEVEL 3: CLONING & BRANCHING CLONE A REPO The IT department installed an OS update on your workstation - and wiped the hard drive in the process. Clone the Pet Shop repo from git@example.com:example/petshop.git so you can resume work. $ git clone git@example.com:example/petshop.git LIST REMOTES Our repo is cloned locally, but how do we check to a list of our remotes? Lets get a list of all our remotes with a verbose output. $ git remote -v CREATE A BRANCH We need to add a section for the pet grooming salon on the site. You want to isolate this new feature from your other work. Create a new branch named grooming. $ git branch grooming SWITCH TO BRANCH You've made the new branch, but your commits are still going to the old one. Switch to the grooming branch. $ git checkout grooming COMBINE BRANCH I You've finished work on the grooming branch and are ready to bring your work back into master. First, check out the master branch… $ git checkout master COMBINE BRANCH II ...Now bring your changes from the grooming branch into the ...master branch. $ git merge grooming BRANCH SHORTCUT The pet shop wants to try selling yet another product line! Let's do this one in a branch in case it gets cancelled like the others. Using a single command, create and check out an octopus branch. https://www.codeschool.com/courses/git-real Page of8 14
  • 9. $ git checkout -b octopus LEVEL 4: COLLABORATION BASICS SEND CHANGES You've committed some work so now it's time to share! Push it out for your co-workers to see. $ git push GET CHANGES Looks like your co-worker pushed some changes before you did! Your push was rejected. Retrieve the latest changes, and merge them into your branch in one step. $ git pull FIX CONFLICTS Git is reporting a conflict with your co-worker's changes in "index.html". Just discard his changes, and keep your own (the HEAD). Problem: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Our Cat-alog</title> </head> <body> <nav> <ul> <<<<<<< HEAD <li><a href="cat.html">Cats</a></li> <li><a href="dog.html">Dogs</a></li> ======= <li><a href="cat.html">Felines</a></li> <li><a href="dog.html">Canines</a></li> >>>>>>> 6a487f9eb0e0a5110bdf2a45a4f5dbcc3d4eec53 </ul> </nav> </body> </html> Solution: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Our Cat-alog</title> </head> <body> <nav> <ul> <li><a href="cat.html">Cats</a></li> <li><a href="dog.html">Dogs</a></li> </ul> </nav> </body> </html> https://www.codeschool.com/courses/git-real Page of9 14
  • 10. MARK FIXED Mark the conflict in index.html as resolved. $ git add index.html COMMIT FIX Last, commit your merged changes. Don't forget to add a message so we know what the commit was about! $ git commit -m “Change fix” LEVEL 5: BRANCHING PUSH BRANCH A new kind of pet is for sale at the store! Maybe this one will catch on with the public. You've committed your work to the local hamsters branch; now publish this branch in the origin repo. $ git push origin hamsters GET REMOTE BRANCH "git branch -r" does not query the remotes to check for new branches. In order to see a new remote branch you first have to do a fetch or a pull. So retrieve the remote "weasel" branch. $ git fetch REMOTE BRANCHES Your co-worker said he wants you to look over a new branch on "origin", but he didn't tell you its name. Get a list of remote branches. $ git remote show origin DELETE ON REMOTE Guess how the product launch went with the weasels? Better delete the "weasel" branch on “origin". $ git push origin :weasel BRANCH STATUS Wait, did you already pull that branch locally? Check for stale branches that are tracking “origin". $ git remote show origin CLEAN BRANCHES https://www.codeschool.com/courses/git-real Page of10 14
  • 11. You still have a stale local branch tracking the now-deleted origin/weasel. Clean up your local references. $ git remote prune origin LIST TAGS With the weasel threat eliminated, the pet store wants to deploy the site. Let's see, what was the previous version number? Display the tags to find out. $ git tag CREATE TAG Ah, yes, the last release was "v1.3.1". You've added the hamsters, so it would be best to release this as "v1.3.2". Create a tag accordingly. $ git tag -a v1.3.2 -m "Version 1.3.2” SEND TAGS Push your tag to origin. $ git push —tags RETRIEVE TAG The client is requesting that you roll back to the prior release. (Seriously? What could have gone wrong with the hamsters?) Retrieve the release tagged “v1.3.1". git checkout v1.3.1 LEVEL 6: REBASE BELONG TO US REBASE I You've made some commits to a feature branch, but you've also committed a hotfix on master that would make a merge messy. Check out the kennel branch so you can rebase it on master. $ git checkout kennel REBASE II OK, you're on the kennel branch. Our goal is to be able to merge kennel back into master without conflicts or a merge commit. Rebase the current kennel branch on master. $ git rebase master REBASE III $ git checkout master https://www.codeschool.com/courses/git-real Page of11 14
  • 12. REBASE IV We're on master, and we know the kennel will merge cleanly. Go ahead and merge in the kennel branch. $ git merge kennel REMOTE I Your co-worker has pushed changes to the master branch on the origin repo. Retrieve it without merging it so we can replay our work on top of it. $ git fetch REMOTE II Now that your local repo knows of the latest changes on origin/master, move your master commits after the commits from origin/master. $ git rebase CONFLICT I Your co-worker has pushed before you yet again. Better fetch the changes… $ git fetch CONFLICT II Now run another rebase to move your commit after the latest fetched one. $ git rebase CONFLICT III Uh, oh! Looks like the rebase is in conflict this time! Edit index.html to fix the conflicting lines. We want to keep our version with Cats and Dogs. Problem: <nav> <ul> <<<<<<< HEAD <li><a href="cat.html">Cats</a></li> <li><a href="dog.html">Dogs</a></li> ======= <li><a href="cat.html">Felines</a></li> <li><a href="dog.html">Canines</a></li> >>>>>>> Add dogs. </ul> </nav> Solution: <nav> <ul> <li><a href="cat.html">Cats</a></li> <li><a href="dog.html">Dogs</a></li> </ul> </nav> https://www.codeschool.com/courses/git-real Page of12 14
  • 13. CONFLICT IV Now mark the conflicts in "index.html" as resolved. $ git add index.html CONFLICT V Now that all conflicts have been resolved and those files added, continue the current rebase in process. $ git rebase —continue LEVEL 7: HISTORY AND CONFIGURATION SHORT HISTORY All those e-mail addresses and SHAs are making it hard to see commit messages in your history. Try viewing the log with one commit per line. $ git log —pretty=oneline SHOW CHANGES The client called with an urgent question about chew toys, and now you can't remember what you last modified. Bring up a summary of file changes. $ git diff BRANCH CHANGES You've finished adding elephants to the catalog. You need to write up a change log for the client, and you want to ensure you don't miss anything. Compare the master branch to your elephant branch to show what's new. $ git diff master elephant ANCESTOR COMMITS You rebased your latest commit after a commit from your co-worker, but now the page is rendering strangely. To figure out why, get a diff that includes the previous commit, as well as its parent. $ git diff HEAD^^ HISTORY WITH DIFF $ git log —patch WHOSE LINE IS IT? Wait, what? You don't understand these lines in index.html. You'd better find out who committed them, so you can ask them what they're supposed to do. https://www.codeschool.com/courses/git-real Page of13 14
  • 14. $ git blame index.html IGNORE FILES Your server writes files to the logs directory. You're not going to commit them, but they keep appearing in your git status output, and you'd like them not to. Edit your .gitignore file to ignore all files in the logs/ directory whose names end in .log. #Enter text here logs/*.log CONFIGURATION Just for this repo, set the user.email value to admin@example.com. $ git config user.email admin@example.com GLOBAL CONFIG Set your name as the user.name value for all Git repos. $ git config --global user.name "Michael Jackson” ALIAS commit just won't suffice for your code. You need a command that conveys the importance of the work that you're entrusting to Git. Alias git commit to git beholdmyamazingcode (or something equally awesome). $ git config --global alias.beholdmyamazingcode commit https://www.codeschool.com/courses/git-real Page of14 14