Main sponsor Git Luca Milanesio Picasso Monet Matejko
- Slides: 112
Main sponsor Git Luca Milanesio Picasso Monet Matejko + Canaletto Malczewski + Chelmonski The Productive Programmer Introduction to Scala The Power of Retrospection Android programming Neal Ford Hubert Plociniczak Linda Rising Sang Shin
Agenda • SCM and Git Concepts • Git quick start • Branching and merging • Resolving conflicts • Reverting changes • Working with tags. co • • Git remotes Git on the server Git peer-to-peer Git democracy LMIT Software Limited – www. lmitsoftware. com
Who’s that guy ? Luca Milanesio LMIT Limited – Director / co-founder of Git. Enterprise. com • Jenkins (formerly Hudson) contributor since 2007 founder of hudson-mobi. com • Over 18 years of experience in Software and Services Development and Application Lifecycle • Worked for major UK, EU and US Customers – Banking, Retailers, Industry, Finance, Telecoms, Utilities, Government. co LMIT Software Limited – www. lmitsoftware. com
About SCM … remember ? SCM = Source Code Management ü Multiple revisions of files ü Commit and rollback changes ü Define change-sets ü Tag important releases ü Manage branches of development ü Integrate the work of multiple teams together Picture courtesy of globalnerdy. com - All rights kindly reserved . co ü … and much more LMIT Software Limited – www. lmitsoftware. com
Brief history of Open. Source SCMs Local SCMs (versions kept on local filesystem) • SCCS (1972) … I was not yet born, don’t remember • RCS (1982) the most widely used on Unix Server-based SCMs (central repository server) • CVS (1990) first widely used SCM server • Subversion (2000) first widely Internet SCM … and then let’s to go distributed … • DCVS. co (2002) who has ever used it ? LMIT Software Limited – www. lmitsoftware. com
Centralised vs. distributed ? How many of you are using central repositories ? • CVS-boys … raise your hands ! • SVN-guys … it’s your turn ! How many are for distributed repositories ? • Mercurial-scientists. . . raise your hands !. co LMIT Software Limited – www. lmitsoftware. com
Who’s right ? Central SCM • Unique “source of truth” • Central back-up • Seamless alignment for all developers • Security and access control Distributed SCM • Community code-base • No single-point-of-failure • Peer-to-peer alignment • Continuous branching and merging. co LMIT Software Limited – www. lmitsoftware. com
Why GIT ? It’s all about Bit. Keeper fault: they broke up with Linus Torvalds … and I’m not kidding Story: • Linux Kernel SCM: Bit. Keeper • Apr 2005 – Linus writes PERL scripts for Linux Kernel SCM • Jul 2005 … Git 0. 99 is out ! Git principles: • • Allow the Bit. Keeper SCM workflow Use CVS as the “not-to-do” example Check and prevent corruption Make it FFF … FAST !. co LMIT Software Limited – www. lmitsoftware. com
BORED of too much theory ?
Let’s experiment Git in action !
Git installation (Ver. >=1. 6) • Linux (Git favourite of course !) – Ubuntu: sudo apt-get install git-core – other Linux ? … best from source code http: //git-scm. com/ • Mac OSX – http: //code. google. com/p/git-osx-installer/ • Windows – http: //code. google. com/p/msysgit/ (sucks … but it’s your fault not using Unix) – Cygwin HIGHLY RECOMMENDED (mandatory IMHO). co LMIT Software Limited – www. lmitsoftware. com
Step 1 – Git repository § create project § cd into project § $ git init . co LMIT Software Limited – www. lmitsoftware. com
Step 2 – Git identity § Define your full name § Define your e-mail § Everything stored in. git/config . co LMIT Software Limited – www. lmitsoftware. com
Step 3 – Add some files and commit § Create some files § Add to GIT (default = recursive) § Commit . co LMIT Software Limited – www. lmitsoftware. com
Step 4 – Inspect GIT log § Get GIT history of commits § Display changes . co LMIT Software Limited – www. lmitsoftware. com
Too simple ? … let’s add some states • Three states of Git files 1. Unstaged 2. Staged 3. Clean git add git commit Picture courtesy of Pro. Git. org . co LMIT Software Limited – www. lmitsoftware. com
State 1. unstaged • Create a new file • Change an existing file • Check status . co LMIT Software Limited – www. lmitsoftware. com
State 2. staged • Add the two files to staging area • Check status . co LMIT Software Limited – www. lmitsoftware. com
State 3. work directory clean • Commit the staging area • Check status . co LMIT Software Limited – www. lmitsoftware. com
Display Git lifecycle • Add another file and make some changes • $ git gui . co LMIT Software Limited – www. lmitsoftware. com
Stage with git gui • Select files and chose “Stage to commit” . co LMIT Software Limited – www. lmitsoftware. com
Commit with git gui • Enter commit message and click “commit” . co LMIT Software Limited – www. lmitsoftware. com
Git graph log with gitk . co LMIT Software Limited – www. lmitsoftware. com
Playtime is over
Git stores the whole file • Git is different from SVN: no diffs, just whole files • Git stores changed files between snapshots (Bit. Keeper docet) Picture courtesy of Pro. Git. org . co LMIT Software Limited – www. lmitsoftware. com
Git object types: blobs • Git stores all files (and their versions) as objects (blobs) • Each object has a SHA-1 160 -bit identifier • SHA-1 provides: – Unique Global ID – Integrity check • Example: – File content: “You're GIT too” – SHA-1: bbecf 72783 dfba 9 e 0243 e 13 dbb 5 fb 04 ed 39 ed 4 e 4 (Hex) • Track content (not files) • Automatically detect renames … cool !. co LMIT Software Limited – www. lmitsoftware. com
SHA-1 ? WTF … • Why Linus Torvalds has chosen SHA-1 hashing ? – Need for track content globally – SHA-1 collision probability is 1/251 • What happens if two files have same SHA-1 ? – BOOM ! • What is the probability of it ? – World’s population (7 BN people) sharing files of 10 times Linux Kernel • Possible ? More likely to be hit by a 15 KM asteroid NOW !!! . co LMIT Software Limited – www. lmitsoftware. com
Git object types: commits and trees • Git tree identifies a snapshot (set of files) • Git commit identifies – – Author / Committer Commit message Timestamp Tree Picture courtesy of Pro. Git. org . co LMIT Software Limited – www. lmitsoftware. com
Git history: graph of commits • Every commit points to its predecessor • Series of commits make Git repository history Picture courtesy of Pro. Git. org . co LMIT Software Limited – www. lmitsoftware. com
Where are Git objects ? • Git objects are in. git/objects • SHA-1 identify directory / file . co LMIT Software Limited – www. lmitsoftware. com
Curious about Git objects ? • Git objects are compressed • Use git show to display content . co LMIT Software Limited – www. lmitsoftware. com
Getting lost ? • How to remember SHA-1 hashing codes ? • How Git stores the “pointers” to Commit graph ? • Git references are the solution ! – Head of the Git history – Intermediate tags – Branch points – Relative points . co LMIT Software Limited – www. lmitsoftware. com
Git references • References: “labels” for Git SHA-1 commit IDs • Stored as files under. git/refs • Reference types: – Tags – Heads (branches) • HEAD is a special ref: always points to head of current branch. . co LMIT Software Limited – www. lmitsoftware. com
How Git commits graph looks like ? Reference Commit Tree Picture courtesy of Pro. Git. org . co LMIT Software Limited – www. lmitsoftware. com
What is a branch for Git ? • Git named branch = reference to a commit ID (head of branch) • Git supports “network” of commits, with named and unnamed branches . co … don’t know why Git reminds me some “underground” branches LMIT Software Limited – www. lmitsoftware. com
Real-life Git branches Think I’m exaggerating ? Look at this example (it’s real, swear !) . co LMIT Software Limited – www. lmitsoftware. com
Let’s practice on Git branches !
Wear “life jacket” first • Get Git bash extensions source git/contrib/completion/git-completion. bash • Redefine prompt export PS 1='W$(__git_ps 1 " (%s)") $ ’ . . . and your current branch is visible on your prompt: you will not get lost . co LMIT Software Limited – www. lmitsoftware. com
Creating branches • Create branch create a new ref to current commit . co LMIT Software Limited – www. lmitsoftware. com
Switching branch • Use git checkout to switch branch • Current displayed branch changed to experimental • Note that HEAD points to experimental . co LMIT Software Limited – www. lmitsoftware. com
Commit on branch • Add a new commit to experimental branch • See the new branch graph (gitk) . co LMIT Software Limited – www. lmitsoftware. com
Merge • When experiments are completed … merge back ! – Checkout master – Merge experimental . co LMIT Software Limited – www. lmitsoftware. com
Git graph after merge Let’s have a look on the result with gitk • Merge-type applied: Fast-forward (move refs in history) • Branch has been “flattened” • Experimental just another ref to master . co LMIT Software Limited – www. lmitsoftware. com
Git recursive-merge • Let’s create some divergence • Changes on both master and experimental • Fast-forward merge = move branch ref to another commit ID. co LMIT Software Limited – www. lmitsoftware. com
Git diverging branches • Use gitk --all to display all branches NOTE: no args displays just current branch • experimental is really diverging from master . co LMIT Software Limited – www. lmitsoftware. com
Git recursive merge • Let’s merge again with master • This is a real merge folks ! NOTE: Merge is a Git commit: you can associate a comment, or revert it later ! Don’t be scared by Git-managed. co merge LMIT Software Limited – www. lmitsoftware. com
Merge alternatives: rebase Picture courtesy of Pro. Git. org . co LMIT Software Limited – www. lmitsoftware. com
Git rebase in action Let’s diverge again between master and experimental Magic ! … rebase flattens the branching history. co LMIT Software Limited – www. lmitsoftware. com
Git graph after rebase Experimental is no more a diverging branch NOTE: Marconi’s test is on “unnamed branch” and experimental branch history has changed !. co LMIT Software Limited – www. lmitsoftware. com
Merge alternatives: squash origin C 1 C 2 C 3 C 4 C 5 C 6 mywork origin C 1 C 2 C 3 C 4 C 3’+C 4’ mywork . co LMIT Software Limited – www. lmitsoftware. com
Git squash in action • Get branch changes but do not join them • git merge –squash experimental commit . co LMIT Software Limited – www. lmitsoftware. com
Git branch graph after squash • Branches are still diverging • Get all the branch changes in a single commit (squash changes together). co LMIT Software Limited – www. lmitsoftware. com
Merge alternatives: cherry-pick origin C 1 C 2 C 3 C 4 C 5 C 6 mywork origin C 1 C 2 C 3 C 4 C 5 C 6’ mywork . co LMIT Software Limited – www. lmitsoftware. com
Merge alternatives: cherry-pick • Get individual commit IDs • Apply individual changes to another branch . co LMIT Software Limited – www. lmitsoftware. com
Git branch graph after cherrypick • Individual commit has been copied from teslatest • Both branches are kept . co LMIT Software Limited – www. lmitsoftware. com
Too easy ? … let’s create some conflict !
Merge conflict Same file changed, same range, two different branches . co LMIT Software Limited – www. lmitsoftware. com
Resolving conflict • Get list of conflicts with git status • Display and edit conflicted file . co LMIT Software Limited – www. lmitsoftware. com
Completing merge • Add edited file to stage • Commit and finalise the merged commit … wasn’t that scary isn’t it ? . co LMIT Software Limited – www. lmitsoftware. com
Rebase / cherry-pick conflict Same file changed, same range, two different branches . co LMIT Software Limited – www. lmitsoftware. com
Don’t panic … unnamed branch • Check in which branch you are • Check files in conflict . co LMIT Software Limited – www. lmitsoftware. com
Resolve conflict and continue rebase • Resolve conflicts • Continue rebase . co LMIT Software Limited – www. lmitsoftware. com
Got lost with commands, merge and conflicts ?
Merge recap Type of merge Conflict when git merge Same file, same range Branches merged (keep branch history) git rebase Same file, same range Fast-forward, flatten history git merge --squash Same file, same range Keep branches, apply changes git cherry-pick Same file, same range Keep branches, apply individual commits . co Branch results LMIT Software Limited – www. lmitsoftware. com
Reverting changes
Git is powerful and dangerous • Git has full control on history – Amend existing commits – Remove commits – Revert changes • Be careful: you could destroy your history ! • Be even more careful: history revert is unrecoverable SCARY !!!!! . co LMIT Software Limited – www. lmitsoftware. com
Change existing commits • Git commit support the “amend” option to overwrite committed data • What can be amended – File changes – Author / comment – Date • The original commit will disappear: amend is NOT revertible (but just amended again). co LMIT Software Limited – www. lmitsoftware. com
Amend last commit • Let’s display the last commit on master . co LMIT Software Limited – www. lmitsoftware. com
Amend last commit • Let’s change commit content . co LMIT Software Limited – www. lmitsoftware. com
Git reset: back to the past • Git reset allows to: – Put committed data back to the working dir soft reset – Remove completely committed data hard reset • Git reset is NOT revertible • You want to reset ? – – Do you really need it ? Do you really want it ? What do you want to achieve ? … and then think again …. co LMIT Software Limited – www. lmitsoftware. com
Soft reset Remove the last commit and put changes back to workdir Hint: master~1 = reference to “one commit before master head” Commit is lost, but you still have the changes in workdir. co LMIT Software Limited – www. lmitsoftware. com
Hard reset Remove commit and all the changes associated Commit is lost FOREVER: there is no way to restore the data. co LMIT Software Limited – www. lmitsoftware. com
Git revert • Git revert allows to: – Revert the changes and to workdir – Revert the changes and create a “reverted commit” • Git revert is revertible • Revert = negative commit (eliminates effect of reverted commit) . co LMIT Software Limited – www. lmitsoftware. com
Display last commit • Let’s display the last commit changes on master . co LMIT Software Limited – www. lmitsoftware. com
Create reverted commit • Let’s revert last commit . co LMIT Software Limited – www. lmitsoftware. com
Now: how to revert the revert ? • Reverted commit is a commit • Use reset to eliminate the revert operation . co LMIT Software Limited – www. lmitsoftware. com
Working with Tags
Importance of Git tags • Why using tags ? … yeah, you know it • Why is MORE IMPORTANT in Git than in SVN ? – Git commit IDs is SHA-1 hashing (WTF $!#@$!%@^!) – Tags = reference to a commit (zero payload) • Type of Git tags – Lightweight tags (simple Git ref to a commit ID) – Annotated tags (author, description, signature). co LMIT Software Limited – www. lmitsoftware. com
Lightweight tags Let’s create a lightweight tag … that’s easier to remember than b 7 dbbe 69 f 0 be…. !. co LMIT Software Limited – www. lmitsoftware. com
Fully annotate tags • Fully annotated tags contains meta-data: – – – Timestamp Author name and e-mail Description Commit ID GPG Digital Signature • Create your private GPG Key-pair first – GPG Public Key identify your user – GPG Private Key is used to sign content (tags, commits) – Exchange GPG Public Key with your peers. co LMIT Software Limited – www. lmitsoftware. com
Create GPG Key pair . co LMIT Software Limited – www. lmitsoftware. com
Create annotated tag • Let’s create a fully annotated and signed tag • Tags are just Git references . co LMIT Software Limited – www. lmitsoftware. com
Git remote management
Git nature: peer-to-peer distributed • Git designed to be distributed – – Global unique IDs for files and commits (SHA-1) Completely disconnected operations Rich set of merging capabilities Compression and integrity check • Natural way of using it is peer-to-peer … the Linus way, yeah . co LMIT Software Limited – www. lmitsoftware. com
Remote Git repositories • Points to other’s people repository – Remote Git servers / location – Remote Git branches • Example: clone GIT source code repository via “remote” – git clone git: //git. kernel. org/pub/scm/git. git . co LMIT Software Limited – www. lmitsoftware. com
Inspecting remote pointers • List of remote Git repositories Name “origin” refers to remote Git repository • List of remote Git branches . co LMIT Software Limited – www. lmitsoftware. com
Push changes to remote Git repository • Add pointer to remote Git repository • Push all local branches to remote Git repository . co LMIT Software Limited – www. lmitsoftware. com
Getting remote Git repository updates 1. Fetching remote changes with git fetch 2. Merge (or rebase) changes . co LMIT Software Limited – www. lmitsoftware. com
Getting changes: shortcuts 1. Use git pull for merging with remote changes git pull = git fetch + git merge … beaware of the branches merge mess ! 2. Use git fetch + git rebase with a macro: git update = !sh -c 'git stash clear && git stash && git fetch origin && git rebase origin/master && git stash pop’ git update = git fetch + git rebase … flat and clean history … seems like SVN isn’t it ? . co LMIT Software Limited – www. lmitsoftware. com
Git repositories (local/remote) recap . co LMIT Software Limited – www. lmitsoftware. com
Choosing your Git Server
Public Git Server: github Many choices … but github is the best ! 1. Create your SSH Key-pair ssh-keygen -t rsa -b 2048 2. Create your free acount on: https: //github. com/signup/free 3. Create your repository on: https: //github. com/repositories/new 4. Add your remote git remote add origin git@github. com: lucamilanesio/33 degree. git . co LMIT Software Limited – www. lmitsoftware. com
Private Git Server: Git. Enterprise Many choices … but this is the best for FREE 1. Create your SSH Key-pair (optional: you can use HTTP/basic auth, firewall frendly) ssh-keygen -t rsa -b 2048 2. Create your free acount on: https: //gitent-scm. com/gitent/users/Sign. Up. git 3. Create your repository on: https: //gitentscm. com/gitent/repository/Repository. Creation. git 4. Add your remote git remote add origin ssh: //lmilanesio@gitentscm. com/gitentdevelopment/33 degree. co LMIT Software Limited – www. lmitsoftware. com
3 rd choice: make your own ! • Installed on your network, running on your hardware • NOTE: make daily backups … GIT is dangerous ! • Gitosis (http: //eagain. net/gitweb/? p=gitosis. git) – Users / Groups / Keys – Repository management – Everything managed with Git Management Repository • Gerrit (http: //code. google. com/p/gerrit/) – Full Web-based Interface – Users / Groups integrated with LDAP, Open. ID, … – Full repository and security. LMIT management. co Software Limited – www. lmitsoftware. com
Git collaboration: anarchy
Everybody fetch/pull from each other Anna John Cathy Linus Luke Peter Nobody pushes: everybody fetch or pull Every Git repository has the same importance. co LMIT Software Limited – www. lmitsoftware. com
How does it work ? • Run your own Git server with git daemon • Others can clone and fetch from your repository • You see them fetching . co LMIT Software Limited – www. lmitsoftware. com
Git collaboration: dictator and lieutenants
Developers fetch/pull, dictator pushes git push Developers pull, Lieutenants integrate Dictator get integration branches together: he is the only one that PUSH to Git Picture courtesy of Pro. Git. org . co LMIT Software Limited – www. lmitsoftware. com
Git. Hub variant git push Developers pull from “blessed” and have their own public Git Integration manager is the Dictator Picture courtesy of Pro. Git. org Revolution allowed: developer nominates himself “new dictator”. co LMIT Software Limited – www. lmitsoftware. com
Git Democracy
Unique central repository Everybody can push / pull from shared Git Repository Central repository dies elections of new Picture courtesy of Pro. Git. org repository. co LMIT Software Limited – www. lmitsoftware. com
Back to centralisation ? WTF ? • Does it seems like SVN ? … much more guys • Git Democracy vs. SVN – Horizontal collaboration between developers (P 2 P) – Continuous branching / merging – “promotions” of changes through voting (Gerrit model) – Control over integration / release • Does it seems like Git is mature for the. co ? LMIT Software Limited – www. lmitsoftware. com Enterprise
Git branching model Picture courtesy of Pro. Git. org . co LMIT Software Limited – www. lmitsoftware. com
Working with topic branches • Developers work on topics • Code-review / votes promote them to master • Topics branches removed after merge • NOTE: better rebase than merge Picture courtesy of Pro. Git. org . co LMIT Software Limited – www. lmitsoftware. com
Topic branches example Developer A starts working on topic-1 Developer B starts working on topic-2 . co LMIT Software Limited – www. lmitsoftware. com
Code-review: merge topic-1 Get topic-1 code and code-review on integration branch Everything’s fine: commit the merge and remove topic-1. co LMIT Software Limited – www. lmitsoftware. com
Code-review: merge topic-2 Repeat the same with topic-2 . co LMIT Software Limited – www. lmitsoftware. com
Release manager: merge integration Release manager decides about releasing integration branch NOTE: No conflicts are generated all merges are from integration branch. co LMIT Software Limited – www. lmitsoftware. com
Further reading and references Further reading Ø Pro. Git: http: //progit. org/ Ø Git cheat sheets: http: //help. github. com/git-cheat-sheets/ Git Services: Ø github: http: //github. com Ø Git. Enterprise: http: //gitenterprise. com . co LMIT Software Limited – www. lmitsoftware. com
Thank you for your patience, You resisted 3 h … YEAH !
Main sponsor BOF: Hack your company Jakub Nabrdalik Picasso Matejko + Canaletto Malczewski + Chelmonski BOF: Web framework shootout BOF: Future of Java EE BOF: Those broken, broken class loaders Błażej Bucko, Tomasz Dziurko, Wojciech Erbetowski, Łukasz Kuczera, Paweł Szulc Alexis Moussine-Pouchkine Jevgeni Kabanov
- 라즈베리 gpio
- Monet picasso van gogh da vinci
- Picasso git
- Agnieszka matejko uwm
- Famous polish painters
- Dynastia jagiellonów
- Regina matejko
- Jan alojzy matejko
- Unia lubelska
- Matejko 3 maja
- Jan matejko prezentacja
- La prugna monet
- Camp de roselles monet
- Claude monet seascapes
- Impresionismus
- Where was claude monet born
- Monet 1899 london
- Claude monet serie
- Impressionism (1865–1885)
- Monet campo de papoulas
- Manet monet renoir
- Giuseppe verdi tesina terza media
- Monet e l'arte giapponese
- Claude monet medium
- Impression sunrise claude monet 1872 oil on canvas
- Claude monet impresja
- Salvatore quasimodo schema
- Claude monet portret
- Camille monet on her deathbed
- Claude cornac ent
- Claude monet snídaně v trávě
- Le monet cumbres
- Monet falaise etretat
- Edoard manet
- A quel courant artistique appartient claude monet
- Ent claude cornac
- Monet n
- Bouquet de tournesols claude monet
- Sponsor roadmap
- Sponsor by
- Adult sponsor
- Contratto per sponsor pubblicitario
- Bonus sponsor tiens
- Pedro menendez de aviles sponsor
- Megan jacques
- Project controls
- What was de aviles goal
- Prosci sponsor roadmap
- The southside baptist church sponsor a festival
- Katarzyna piwowarska ue katowice
- And now a word from our sponsor
- Sponsor letter for visa uk
- Npqsl sponsor comments examples
- Prosci pct assessment
- Curriculum led budget npqh
- Sponsor
- The sponsor must submit an ind safety
- Jacques cartier
- Mentor versus sponsor
- Sponsor
- Bonus sponsor
- Implied main idea
- Void main int main
- The will future
- Krvaceni do git
- Periodontal ligament
- Git
- Rapidjson object to string
- Git
- Git gastrointestinální trakt
- Git gastrointestinální trakt
- Plika nasolabialis
- Git organs
- Jenkins git 연동
- Git global username
- Git prophylaxis
- Rebase vs merge git
- Git
- Redmine vs trac
- Git anatomy
- Git
- Nnn github
- Blood supply of celiac trunk
- Git global username
- Pyloric sphincter histology
- Git secretions
- Oneflow github
- Tunica serosa
- Git
- Flora git drop
- Tbd git
- Pancreatic hormones
- Tweak hub.io
- Git venous drainage
- Git object model
- Whats git hub
- Git global name
- Git
- Git scm com
- Git
- Git hub io
- Git in biochemistry
- Git powerpoint
- Create eclipse project from git repository
- Peritronitis
- Git struktur
- Pytom
- Git lft
- Oesophagus
- What is git
- Git file lifecycle
- Ast more than alt
- Install git jupyter notebook