http flic krp6 o P 7 x 7
- Slides: 60
http: //flic. kr/p/6 o. P 7 x 7 Version Control with Git
Why track/manage revisions?
Backup: Undo or refer to old stuff http: //git-scm. com/book/en/Git-Branching-Basic-Branching-and-Merging
Branch: Maintain old release while working on new http: //git-scm. com/book/en/Git-Branching-Basic-Branching-and-Merging
Collaborate: Work in parallel with teammates http: //git-scm. com/book/en/Distributed-Git-Distributed-Workflows
Version Control Systems (VCSs) • Help you track/manage/distribute revisions • Standard in modern development • Examples: older – – – newer – Revision Control System (RCS) Concurrent Versions System (CVS) Subversion (SVN) Git Our focus
Git. Hub-User Perspective You Working Dir Local Repos Git. Hub Remote Repos
Let’s begin with an example… You Git. Hub
Configure your Git client (Rails Tutorial 1. 3. 1) • Install Git • Check config info: $ git config --list user. name=Scott Fleming user. email=Scott. Fleming@memphis. edu • Fix if necessary: $ git config --global user. name "John Doe" $ git config --global user. email jdoe@memphis. edu
Log into Git. Hub and create a repos (with add README option) You Git. Hub Remote Repos
$ git clone https: //github. com/sdflem/comp 4081_demo. git You Working Dir Local Repos Git. Hub Remote Repos
$ rails new comp 4081_demo You Working Dir Local Repos Git. Hub Remote Repos
$ cd comp 4081_demo $ git add -A $ git commit –m "Created Rails project skeleton" You Working Dir Local Repos Git. Hub Remote Repos
$ git push You Working Dir Local Repos Git. Hub Remote Repos
Questions to answer You Working Dir How organized? Local Repos What operations? Git. Hub Remote Repos
How the repos is organized http: //git-scm. com/book/
How the repos is organized Commits (from oldest to newest; hashes as commit IDs) http: //git-scm. com/book/
How the repos is organized Snapshot of all files at each commit http: //git-scm. com/book/
How the repos is organized Branch (last commit) http: //git-scm. com/book/
How commit works Before http: //git-scm. com/book/
How commit works After http: //git-scm. com/book/
Common Workflow 1. 2. 3. 4. 5. 6. 7. 8. Create temp local branch Make changes Checkout temp branch in local branch Edit/Add/Commit on temp branch Checkout master branch Merge with Pull to update master branch Git. Hub repos Merge temp branch with updated master Delete temp branch Push to update server repos
Organization with two branches
Organization with two branches Last commit of each branch
Organization with two branches Currently checked out branch
Common Workflow 1. 2. 3. 4. 5. 6. 7. 8. Create temp local branch Checkout temp branch Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos
How git branch works $ git branch testing Before
How git branch works $ git branch testing After
Common Workflow 1. 2. 3. 4. 5. 6. 7. 8. Create temp local branch Checkout temp branch Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos
How git checkout works $ git checkout testing Before
How git checkout works $ git checkout testing After
Common Workflow 1. 2. 3. 4. 5. 6. 7. 8. Create temp local branch Checkout temp branch Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos
How git commit works with multiple branches Edit some stuff $ git add -A $ git commit –m "blah" Before
How git commit works with multiple branches Edit some stuff $ git add -A $ git commit –m "blah" After
Common Workflow 1. 2. 3. 4. 5. 6. 7. 8. Create temp local branch Checkout temp branch Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos
How git checkout works $ git checkout master Before
How git checkout works $ git checkout master After
Common Workflow 1. 2. 3. 4. 5. 6. 7. 8. Create temp local branch Checkout temp branch Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos
How git pull works Someone else pushed $ git pull Before
How git pull works Someone else pushed $ git pull After
Common Workflow 1. 2. 3. 4. 5. 6. 7. 8. Create temp local branch Checkout temp branch Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos
How git merge works $ git merge testing Before
How git merge works $ git merge testing e 2 b 92 After
Common Workflow 1. 2. 3. 4. 5. 6. 7. 8. Create temp local branch Checkout temp branch Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos
How to delete branches $ git branch -d testing e 2 b 92 Before
How to delete branches $ git branch -d testing e 2 b 92 After
Common Workflow 1. 2. 3. 4. 5. 6. 7. 8. Create temp local branch Checkout temp branch Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos
How git push works $ git push e 2 b 92 Should update server repos (if no one else has pushed commits to master branch since last pull)
Tips • git output contains lots of hints – git status is your friend! • Merging may not be as easy as I showed – E. g. : Multiple collabs updated same parts of file – See Pro Git 3. 2 • Pull before starting temp branch • Team communication important!
Pop Quiz • 5 questions • Update diagram in each – Commit nodes – Branch nodes • Based on actions of Alice and Bob – Collaborating via Git. Hub repo
Start like this Scott Fleming Git. Hub master 11111 master Alice 11111 Bob SF 1
Question 1 • Alice: – $ git clone https: //github. com/whatever. git – $ cd whatever • Bob: – $ git clone https: //github. com/whatever. git – $ cd whatever (include the HEAD node)
Question 2 • Alice: – $ git branch myfix – $ git checkout myfix • (Alternatively) – $ git checkout -b myfix
Question 3 • Alice: – $ rails generate scaffold User … – $ git add -A – $ git commit -m "Added User" # 22222 • Bob: – $ rails generate scaffold Micropost … – $ git add -A – $ git commit -m "Added Micropost" # 33333
Question 4 • Bob: – git push
Question 5 • Alice: – git checkout master – git pull
Appendix
What if… Alice did this: app/models/micropost. rb class Micropost < Active. Record: : Base validates : content, length: { maximum: 140 } end Bob did this: app/models/micropost. rb class Micropost < Active. Record: : Base validates : content, length: { maximum: 120 } end
What if Alice did this? master 33333 11111 22222 myfix $ git merge myfix
$ git merge myfix Auto-merging app/models/micropost. rb Automatic merge failed; fix conflict and then commit result. app/models/micropost. rb class Micropost < Active. Record: : Base <<<<<<< HEAD validates : content, length: { maximum: 140 } ======= validates : content, length: { maximum: 120 } >>>>>>> myfix end To resolve: Manually fix the file; git add and commit
- Git flic
- Http //mbs.meb.gov.tr/ http //www.alantercihleri.com
- Http //pelatihan tik.ung.ac.id
- Xampp alias
- Genetics home reference
- Http://www.freetranslation.com/
- Http blog.ir
- Mbgnet.net
- Http //nssdc.gsfc.nasa
- Stachura edmund
- Http://catedu.es/arasaac/
- Pws.npru.ac.th
- Http://vbabenefits.bswift.com
- Photoelectric effect applications
- T. trimpe 2006 http //sciencespot.net/ answer key
- Teachertech.rice.edu
- ливинтернет
- Http://zh
- Membuat garis html
- Http://smartersott.co
- "http basenacionalcomum mec gov"
- Http://insidechnsf.chnsf.org/
- Http://www.allthingshairy.com grow hair faster
- Http://www.zoho.com
- Padres unidadejecutiva.ml
- Kehadiran.sdm.kemdikbud/kehadiran
- Http//docs.google.com/forms/d/e/1 faip
- Http //intranet/cs
- Evea .uh.cu
- Http://catedu.es/arasaac/
- Http://apps.tujuhbukit.com/covid19/
- T.trimpe 2006 http sciencespot.net
- Http://flowers
- Dgae prepa 4
- Dendro.cnre.vt.edu photosynthesis
- Sinhvien hufi
- Httpsaka
- Treatment options
- Http://www.safesearchkids.com/
- Http://16
- Sso pertanian
- Http://www.finaid.org/calculators/loanpayments.phtml
- Idfish
- Wordle title font
- Microscopes brainpop quiz answers
- Potensi pemanfaatan kelas maya yaitu
- Www.edupalvelut.fi
- Http://www.mesopotamia.co.uk/
- Http //sciencespot.net/
- Http://whats up
- Http://belarustoday.info/?sid=4
- Http //training.itcilo.it/actrav
- Http //www.globalrichlist.com/
- Http://system.windows.media/
- Arasaac.org pictogramas
- Formulageo.blogspot
- Http://www.primaryhomeworkhelp.co.uk
- Http /sciencespot.net/
- Tribologie definition
- Wap treck
- Metric mania answer key lesson 2 mass