SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Downloaden Sie, um offline zu lesen
GITHUB fundamentals to work on legendary projects
1
GITHUB fundamentals to work on legendary projects
By Ravi Shankar
Fork the project which you want to work on. For example I have cloned passionbytes/arrowexp
(main project) to Ravion/arrowexp (forked project). Note that when you fork, you have everything
in sync at that point and will have only one branch – mainly master.
Figure 1 Fork a project
Now, we want to contribute to the main project. The official way is to clone it to the local as
below as the first step.
git clone https://github.com/Ravion/arrowexp.git
This is shown below:
GITHUB fundamentals to work on legendary projects
2
Figure 2 git clone the forked project to local
Note that now we have three things – one is main project, another is the forked master, and the
local copy.
Since you may make changes later, at any point in time, we need to make sure we are syncking
our local code is in sync with main master. This is done by
git remote add upstream
https://github.com/passionbytes/arrowexp.git
Figure 3 Remote repo setting
Assume that at this time, someone changed the main project by editing first number in csv from
90 to 100 and committed.
GITHUB fundamentals to work on legendary projects
3
Figure 4 master edited now (from 90 to 100 on first value)
Now we have a problem. Our local code , neither our forked master are in sync with main project.
So lets issue a sync command, by
git fetch upstream
Figure 5 Syncing with main project
GITHUB fundamentals to work on legendary projects
4
The most important thing is, now the forked master is not updated with sync, only our local copy
is updated:
Figure 6 Left side and right side shows the we just fetched, not updated anything
So lets try now, a powerful command: rebase
git rebase upstream/master and see what happens
Figure 7 The forked project on github is not updated, but local is
This is very important : now we have same code as that of main project and our local , but NOT
THE FORKED PROJECT IN GITHUB
Ignore that for now. Lets start making a change in the csv file, changing value from 100 to 110.
Since we are working on a certain feature or improvement, we will create a branch with the
feature name and we will start building it. This is the command next, assuming that we are
adding a wonderful feature now.
GITHUB fundamentals to work on legendary projects
5
git checkout -b first-wonderful-changes upstream/master
You will now be in that branch.
Figure 8 Creating a branch
Now let’s make changes by editing the CSV file from 100 to 110. Shown below new changes
Figure 9 Editing the code
Now type
git status
GITHUB fundamentals to work on legendary projects
6
Figure 10 Status of the branch
Many things here. We first changed to our branch, then we edited our file. When we look for
status, it will say that there is one file modified now. Now we have to add it for committing,
followed by a commit. After adding it, you cant do any rebase, before committing. We execute
below commands:
git add drivers.csv
git commit -m "first wonderful changes"
git rebase upstream/master (Just making sure nobody made any further
changes from the point we created branch)
You get below.
GITHUB fundamentals to work on legendary projects
7
Figure 11 Adding , Committing and Rebasing
Note that we have not told to update this code yet.
We are taking a coffee break. Meanwhile something is happening in the main project.
We just committed, but not pushed. Now let’s assume that some author is making a change in
the main master project, by editing the same CSV file , last line from 45 to 100 and committed.
Shown below
Figure 12 Main authors(s) editing csv file in main project
How do we make sure that when we push it, we have the latest ?
Just do the following command, and see the effect
GITHUB fundamentals to work on legendary projects
8
git fetch upstream à get the latest changes
git rebase upstream/master -> rebase our code, and replay the changes we
have done
cat drivers.csv à shows that the latest changes are updated, and git had applied
our changes on top
Figure 13Making sure that we are taking latest changes
Now finally, we are going to push it. This is done in two steps. First, we need to create one
remote repo to point to our forked project with our branch name. Then create a pull request from
that branch.
Let’s create one remote repo, pointing to our forked master. Remember we never did any update
yet there.
GITHUB fundamentals to work on legendary projects
9
git remote add ravion
https://github.com/Ravion/arrowexp.git
Figure 14 Add a remote repo to point to our forked master
Next step is to push our changes to this forked master, but to a feature branch. In this way, we
can create as many feature branches and the real forked master remain their as a placeholder as
root of tree.
This is done as:
git push --force-with-lease --set-upstream ravion
first-wonderful-changes
The output tells everything:
Figure 15 Pushing changes to our branch in forked master
GITHUB fundamentals to work on legendary projects
10
Now lets go to GIT, our forked master
Figure 16 Forked master shows a new branch with our changes
Figure 17 Changes in forked master, see branch name
If you look at the CSV file in master, there will not be any change from the first time we pulled.
But look at the branch’s CSV file
GITHUB fundamentals to work on legendary projects
11
Figure 18 Left side in master shows no change, but our branch shows the latest changes syncing
with main master
So far so good. Now we will create a pull request from our local branch.
Figure 19 Creating a PR from feature branch
Now let’s turn the roles. I am going to master, instead of approving the PR, I am giving a
comment to update the value to 150. At the same time, I am changing last row of CSV file to
200.
As a feature owner, now you need to change value, resubmit without creating a new PR, but on
same PR. Here is how file looks in main master
GITHUB fundamentals to work on legendary projects
12
Figure 20 CSV main master changes, asked to change value in first row to 150
OK, let’s come back where we are.
We start with
git checkout first-wonderful-changes à NOTE that no -b option. -b
option means we are creating new branch
Fetch and rebase to sync
git fetch upstream
git rebase upstream/master
and now see
car drivers.csv à you must see latest file
GITHUB fundamentals to work on legendary projects
13
Figure 21 Syncing for next iteration
Now let’s change the value as per the comments by reviewer in main master
Figure 22 Making changes as of review
GITHUB fundamentals to work on legendary projects
14
OK, now , replay what we did before: May be you can choose a different commit message.
Figure 23 Making changes as per review and committing branch again
You can note that, now the changes are available in our forked branch, as well as message gone
to main master for next review. Once reviewed, your branch as well as the main master is
synchronized.

Weitere ähnliche Inhalte

Was ist angesagt?

Api Versioning
Api VersioningApi Versioning
Api VersioningBen Ramsey
 
Concourse CI Meetup Demo
Concourse CI Meetup DemoConcourse CI Meetup Demo
Concourse CI Meetup DemoToshiaki Maki
 
Git workflow in agile development
Git workflow in agile developmentGit workflow in agile development
Git workflow in agile developmentZack Siri
 
Git workflows
Git workflowsGit workflows
Git workflowsXpand IT
 
EGit - Eclipse plug-in for git
EGit - Eclipse plug-in for gitEGit - Eclipse plug-in for git
EGit - Eclipse plug-in for gitTomasz Zarna
 
Say hello world with angular 5
Say hello world with angular 5Say hello world with angular 5
Say hello world with angular 5Abhishek Mallick
 

Was ist angesagt? (9)

Api Versioning
Api VersioningApi Versioning
Api Versioning
 
Git workflows
Git workflowsGit workflows
Git workflows
 
Gitflow Workflow
Gitflow WorkflowGitflow Workflow
Gitflow Workflow
 
Concourse CI Meetup Demo
Concourse CI Meetup DemoConcourse CI Meetup Demo
Concourse CI Meetup Demo
 
Git workflow in agile development
Git workflow in agile developmentGit workflow in agile development
Git workflow in agile development
 
Git workflows
Git workflowsGit workflows
Git workflows
 
IVY: an overview
IVY: an overviewIVY: an overview
IVY: an overview
 
EGit - Eclipse plug-in for git
EGit - Eclipse plug-in for gitEGit - Eclipse plug-in for git
EGit - Eclipse plug-in for git
 
Say hello world with angular 5
Say hello world with angular 5Say hello world with angular 5
Say hello world with angular 5
 

Ähnlich wie Github fundamentals to work with legendary projects

Git 101 - An introduction to Version Control using Git
Git 101 - An introduction to Version Control using Git Git 101 - An introduction to Version Control using Git
Git 101 - An introduction to Version Control using Git John Tighe
 
Checkitmobile - using Git for development
Checkitmobile - using Git for developmentCheckitmobile - using Git for development
Checkitmobile - using Git for developmentGerrit Wanderer
 
Git and Github.pptx
Git and Github.pptxGit and Github.pptx
Git and Github.pptxHitesh670643
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshellalignan
 
BSADD-Git-TRAINING
BSADD-Git-TRAININGBSADD-Git-TRAINING
BSADD-Git-TRAININGbsadd
 
GitFlow Workshop
GitFlow WorkshopGitFlow Workshop
GitFlow WorkshopSyed Imam
 
How to use Git Branch
How to use Git BranchHow to use Git Branch
How to use Git BranchPhuoc Nguyen
 
The gitflow way
The gitflow wayThe gitflow way
The gitflow wayRuijun Li
 
devops-complete-notes-2.pdf
devops-complete-notes-2.pdfdevops-complete-notes-2.pdf
devops-complete-notes-2.pdfRobinRohit2
 
Nina Zakharenko - Introduction to Git - Start SLC 2015
Nina Zakharenko - Introduction to Git - Start SLC 2015Nina Zakharenko - Introduction to Git - Start SLC 2015
Nina Zakharenko - Introduction to Git - Start SLC 2015Nina Zakharenko
 
Git basics with notes
Git basics with notesGit basics with notes
Git basics with notesSurabhi Gupta
 
Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010Matt Gauger
 
Git workshop
Git workshopGit workshop
Git workshopRay Toal
 
Checkitmobile advanced git
Checkitmobile advanced gitCheckitmobile advanced git
Checkitmobile advanced gitGerrit Wanderer
 
Hacking Git and GitHub
Hacking Git and GitHubHacking Git and GitHub
Hacking Git and GitHubEdureka!
 

Ähnlich wie Github fundamentals to work with legendary projects (20)

Git 101 - An introduction to Version Control using Git
Git 101 - An introduction to Version Control using Git Git 101 - An introduction to Version Control using Git
Git 101 - An introduction to Version Control using Git
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Checkitmobile - using Git for development
Checkitmobile - using Git for developmentCheckitmobile - using Git for development
Checkitmobile - using Git for development
 
Git and Github.pptx
Git and Github.pptxGit and Github.pptx
Git and Github.pptx
 
Git and git flow
Git and git flowGit and git flow
Git and git flow
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
 
Git Best Practices.pptx
Git Best Practices.pptxGit Best Practices.pptx
Git Best Practices.pptx
 
BSADD-Git-TRAINING
BSADD-Git-TRAININGBSADD-Git-TRAINING
BSADD-Git-TRAINING
 
Bsadd training-git
Bsadd training-gitBsadd training-git
Bsadd training-git
 
GitFlow Workshop
GitFlow WorkshopGitFlow Workshop
GitFlow Workshop
 
How to use Git Branch
How to use Git BranchHow to use Git Branch
How to use Git Branch
 
Git
GitGit
Git
 
The gitflow way
The gitflow wayThe gitflow way
The gitflow way
 
devops-complete-notes-2.pdf
devops-complete-notes-2.pdfdevops-complete-notes-2.pdf
devops-complete-notes-2.pdf
 
Nina Zakharenko - Introduction to Git - Start SLC 2015
Nina Zakharenko - Introduction to Git - Start SLC 2015Nina Zakharenko - Introduction to Git - Start SLC 2015
Nina Zakharenko - Introduction to Git - Start SLC 2015
 
Git basics with notes
Git basics with notesGit basics with notes
Git basics with notes
 
Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010
 
Git workshop
Git workshopGit workshop
Git workshop
 
Checkitmobile advanced git
Checkitmobile advanced gitCheckitmobile advanced git
Checkitmobile advanced git
 
Hacking Git and GitHub
Hacking Git and GitHubHacking Git and GitHub
Hacking Git and GitHub
 

Kürzlich hochgeladen

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 

Kürzlich hochgeladen (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 

Github fundamentals to work with legendary projects

  • 1. GITHUB fundamentals to work on legendary projects 1 GITHUB fundamentals to work on legendary projects By Ravi Shankar Fork the project which you want to work on. For example I have cloned passionbytes/arrowexp (main project) to Ravion/arrowexp (forked project). Note that when you fork, you have everything in sync at that point and will have only one branch – mainly master. Figure 1 Fork a project Now, we want to contribute to the main project. The official way is to clone it to the local as below as the first step. git clone https://github.com/Ravion/arrowexp.git This is shown below:
  • 2. GITHUB fundamentals to work on legendary projects 2 Figure 2 git clone the forked project to local Note that now we have three things – one is main project, another is the forked master, and the local copy. Since you may make changes later, at any point in time, we need to make sure we are syncking our local code is in sync with main master. This is done by git remote add upstream https://github.com/passionbytes/arrowexp.git Figure 3 Remote repo setting Assume that at this time, someone changed the main project by editing first number in csv from 90 to 100 and committed.
  • 3. GITHUB fundamentals to work on legendary projects 3 Figure 4 master edited now (from 90 to 100 on first value) Now we have a problem. Our local code , neither our forked master are in sync with main project. So lets issue a sync command, by git fetch upstream Figure 5 Syncing with main project
  • 4. GITHUB fundamentals to work on legendary projects 4 The most important thing is, now the forked master is not updated with sync, only our local copy is updated: Figure 6 Left side and right side shows the we just fetched, not updated anything So lets try now, a powerful command: rebase git rebase upstream/master and see what happens Figure 7 The forked project on github is not updated, but local is This is very important : now we have same code as that of main project and our local , but NOT THE FORKED PROJECT IN GITHUB Ignore that for now. Lets start making a change in the csv file, changing value from 100 to 110. Since we are working on a certain feature or improvement, we will create a branch with the feature name and we will start building it. This is the command next, assuming that we are adding a wonderful feature now.
  • 5. GITHUB fundamentals to work on legendary projects 5 git checkout -b first-wonderful-changes upstream/master You will now be in that branch. Figure 8 Creating a branch Now let’s make changes by editing the CSV file from 100 to 110. Shown below new changes Figure 9 Editing the code Now type git status
  • 6. GITHUB fundamentals to work on legendary projects 6 Figure 10 Status of the branch Many things here. We first changed to our branch, then we edited our file. When we look for status, it will say that there is one file modified now. Now we have to add it for committing, followed by a commit. After adding it, you cant do any rebase, before committing. We execute below commands: git add drivers.csv git commit -m "first wonderful changes" git rebase upstream/master (Just making sure nobody made any further changes from the point we created branch) You get below.
  • 7. GITHUB fundamentals to work on legendary projects 7 Figure 11 Adding , Committing and Rebasing Note that we have not told to update this code yet. We are taking a coffee break. Meanwhile something is happening in the main project. We just committed, but not pushed. Now let’s assume that some author is making a change in the main master project, by editing the same CSV file , last line from 45 to 100 and committed. Shown below Figure 12 Main authors(s) editing csv file in main project How do we make sure that when we push it, we have the latest ? Just do the following command, and see the effect
  • 8. GITHUB fundamentals to work on legendary projects 8 git fetch upstream à get the latest changes git rebase upstream/master -> rebase our code, and replay the changes we have done cat drivers.csv à shows that the latest changes are updated, and git had applied our changes on top Figure 13Making sure that we are taking latest changes Now finally, we are going to push it. This is done in two steps. First, we need to create one remote repo to point to our forked project with our branch name. Then create a pull request from that branch. Let’s create one remote repo, pointing to our forked master. Remember we never did any update yet there.
  • 9. GITHUB fundamentals to work on legendary projects 9 git remote add ravion https://github.com/Ravion/arrowexp.git Figure 14 Add a remote repo to point to our forked master Next step is to push our changes to this forked master, but to a feature branch. In this way, we can create as many feature branches and the real forked master remain their as a placeholder as root of tree. This is done as: git push --force-with-lease --set-upstream ravion first-wonderful-changes The output tells everything: Figure 15 Pushing changes to our branch in forked master
  • 10. GITHUB fundamentals to work on legendary projects 10 Now lets go to GIT, our forked master Figure 16 Forked master shows a new branch with our changes Figure 17 Changes in forked master, see branch name If you look at the CSV file in master, there will not be any change from the first time we pulled. But look at the branch’s CSV file
  • 11. GITHUB fundamentals to work on legendary projects 11 Figure 18 Left side in master shows no change, but our branch shows the latest changes syncing with main master So far so good. Now we will create a pull request from our local branch. Figure 19 Creating a PR from feature branch Now let’s turn the roles. I am going to master, instead of approving the PR, I am giving a comment to update the value to 150. At the same time, I am changing last row of CSV file to 200. As a feature owner, now you need to change value, resubmit without creating a new PR, but on same PR. Here is how file looks in main master
  • 12. GITHUB fundamentals to work on legendary projects 12 Figure 20 CSV main master changes, asked to change value in first row to 150 OK, let’s come back where we are. We start with git checkout first-wonderful-changes à NOTE that no -b option. -b option means we are creating new branch Fetch and rebase to sync git fetch upstream git rebase upstream/master and now see car drivers.csv à you must see latest file
  • 13. GITHUB fundamentals to work on legendary projects 13 Figure 21 Syncing for next iteration Now let’s change the value as per the comments by reviewer in main master Figure 22 Making changes as of review
  • 14. GITHUB fundamentals to work on legendary projects 14 OK, now , replay what we did before: May be you can choose a different commit message. Figure 23 Making changes as per review and committing branch again You can note that, now the changes are available in our forked branch, as well as message gone to main master for next review. Once reviewed, your branch as well as the main master is synchronized.