SlideShare une entreprise Scribd logo
1  sur  6
Télécharger pour lire hors ligne
Work on branches in parallel
In this exercise you learn how you can efficiently work in different branches in parallel. A
common situation is that you want to switch to another branch and you want to temporarily
save your work on the current branch. You will learn two possibilities:
● Amend: Commit an unfinished change and replace this commit later with a new,
refined commit using the amend feature of git.
● Stash: Put your change into the git stash area with the stash command
Preparation
Follow exercise 2, “Develop a feature/bug fix” to create a commit on a feature branch based
on the remote tracking branch origin/master.
Start working on another feature
● Create a new local branch based on the remote tracking branch “origin/master”
● You may create the new branch from the History View :
○ Select the project, then click Show In > History (Some views, e.g. in the Java
EE-Perspective, do not have this shortcut, in this case use Team > Show in
History)
○ In the history view click all toggle buttons as shown in the screenshot
(“Link with Editor and Selection”, “Show all changes in Repository”, “Compare
Mode”, “Show all branches”)
○
Click “Create Branch...” on the commit where“origin/master” points to
● Or you may do that from the Repositories View :
select the remote tracking branch origin/master and click Create Branch
● Enter “addMultiplyOperation” as the name of the new branch, make sure the
“Checkout new branch” is selected and click Finish
● Check that now you don’t see the changes of the first exercise anymore in your
workspace.
● Start working on a change, e.g. add a MultiplyOperation, do not commit yet, first
read on.
Save your work temporarily
Now you want to switch to another branch but you want to continue working at your new
feature later on. There are two ways to achieve that: doing a preliminary commit and use
amend later to continue your work or use stash. You may do this exercise twice to try both
ways.
Preliminary Commit
The easiest thing to do is to just commit your work in progress and amend that commit later
to replace the preliminary commit.
● Open the Git Staging View
● Enter a preliminary message, e.g. “WIP ...” for Work in Progress, stage the files to be
committed and click on Commit
Stash
Select Stash Changes on the repository node in the Git Repositories View. As a result
you will get a new node in the view. It contains a list of all the stashed changes. The label
contains the current branch, the id and the commit message of the current commit.
Note that untracked files are not stashed by default. If you are using at least EGit 3.4 you
can include untracked files by checking the corresponding option.
In older versions you have to drag and drop an untracked file to the “Staged Changes” area
before you can stash it.
Switch to another branch
● Now you can switch to the first feature branch “addDivideOperation”, either by double
clicking on the branch node in the Git Repositories View, by selecting “Team >
Switch to > addDivideOperation” or by clicking “Checkout” in the History View.
● Check that your workspace contains the changes you committed in your first feature
(implementing divide) branch. You could now continue working here. For example:
you may want to fix the division by zero issue if it is not already handled. If you do
any changes in the “addDivideOperation” branch don’t forget to commit them before
the next step
● Switch back to the “addMultiplyOperation” branch
Continue working on the branch to add Multiply
Case 1: Preliminary Commit
● Do another change in the workspace improving Multiply.
● Compare your changed project with the first, preliminary commit by selecting
Compare With > HEAD revision. This will show you the changes you will add on top
of the first commit.
● Compare your changed project with the parent commit of your first, preliminary
commit by selecting Compare With > Previous revision. This will show you the
changes you will have in your new commit after the next step.
Create a new commit with the combined changes of your first, preliminary commit
and your current changes
● Open the Git Staging View
● Click the “Amend” button as shown below.
● Now you see again the commit message of the last commit you made in this branch.
Change it to something meaningful, stage the change and click the Commit button.
● In the History View you can now see that your first, preliminary commit was replaced
by the new one.
Case 2: Stash
● In the Repositories View, select Apply Stashed Changes on the stash entry.
● Note that you can apply the stashed change on any commit in your repository. This is
useful if you have started on a branch but you realize that you would like to continue
on another branch. If you apply the stashed commit on another base version this may
lead to conflicts you may have to resolve in this case.
Copyright © 2014 by C. Halstrick, E. Kempin, S. Lay, S. Zivkov, M. Sohn

Contenu connexe

Similaire à Git Tutorial EclipseCon France 2014 - Git Exercise 03 - work on branches in parallel

Git Branching and Merging.pptx
Git Branching and Merging.pptxGit Branching and Merging.pptx
Git Branching and Merging.pptx
tapanvyas11
 
Checkitmobile - using Git for development
Checkitmobile - using Git for developmentCheckitmobile - using Git for development
Checkitmobile - using Git for development
Gerrit Wanderer
 
Checkitmobile advanced git
Checkitmobile advanced gitCheckitmobile advanced git
Checkitmobile advanced git
Gerrit Wanderer
 
Git cheat sheet__grey
Git cheat sheet__greyGit cheat sheet__grey
Git cheat sheet__grey
King Hom
 

Similaire à Git Tutorial EclipseCon France 2014 - Git Exercise 03 - work on branches in parallel (20)

Git Tutorial EclipseCon France 2014 - Git Exercise 06 - interactive rebase
Git Tutorial EclipseCon France 2014 - Git Exercise 06 - interactive rebaseGit Tutorial EclipseCon France 2014 - Git Exercise 06 - interactive rebase
Git Tutorial EclipseCon France 2014 - Git Exercise 06 - interactive rebase
 
Git Branching and Merging.pptx
Git Branching and Merging.pptxGit Branching and Merging.pptx
Git Branching and Merging.pptx
 
Checkitmobile - using Git for development
Checkitmobile - using Git for developmentCheckitmobile - using Git for development
Checkitmobile - using Git for development
 
The benefits of using Git
The benefits of using GitThe benefits of using Git
The benefits of using Git
 
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 4 - review change
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 4 - review changeGit Tutorial EclipseCon France 2014 - Gerrit Exercise 4 - review change
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 4 - review change
 
Chicago alm user group git demo script and notes
Chicago alm user group   git demo script and notesChicago alm user group   git demo script and notes
Chicago alm user group git demo script and notes
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
GDSC Git event 2023.pptx
GDSC Git event 2023.pptxGDSC Git event 2023.pptx
GDSC Git event 2023.pptx
 
Mastering GIT
Mastering GITMastering GIT
Mastering GIT
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Checkitmobile advanced git
Checkitmobile advanced gitCheckitmobile advanced git
Checkitmobile advanced git
 
Developing with versioning and CI/CD
Developing with versioning and CI/CDDeveloping with versioning and CI/CD
Developing with versioning and CI/CD
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
 
E caregitpresentation
E caregitpresentationE caregitpresentation
E caregitpresentation
 
Git cheat sheet__grey
Git cheat sheet__greyGit cheat sheet__grey
Git cheat sheet__grey
 
Git 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawanGit 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawan
 
GIT Rebasing and Merging
GIT Rebasing and MergingGIT Rebasing and Merging
GIT Rebasing and Merging
 
Technical Seminar Series: GIT Pull Requests Best Practices
Technical Seminar Series:  GIT Pull Requests Best PracticesTechnical Seminar Series:  GIT Pull Requests Best Practices
Technical Seminar Series: GIT Pull Requests Best Practices
 
Lab3 RTC Source Control
Lab3 RTC Source ControlLab3 RTC Source Control
Lab3 RTC Source Control
 
Application of Git Revert in different situation
Application of Git Revert in different situationApplication of Git Revert in different situation
Application of Git Revert in different situation
 

Plus de msohn

Code Matters - Eclipse Hackers Git Guide - EclipseCon France 2014
Code Matters - Eclipse Hackers Git Guide - EclipseCon France 2014Code Matters - Eclipse Hackers Git Guide - EclipseCon France 2014
Code Matters - Eclipse Hackers Git Guide - EclipseCon France 2014
msohn
 

Plus de msohn (20)

Project Gardener - EclipseCon Europe - 2018-10-23
Project Gardener - EclipseCon Europe - 2018-10-23Project Gardener - EclipseCon Europe - 2018-10-23
Project Gardener - EclipseCon Europe - 2018-10-23
 
News from Git in Eclipse - EclipseCon EU - 2016-10-26
News from Git in Eclipse - EclipseCon EU - 2016-10-26News from Git in Eclipse - EclipseCon EU - 2016-10-26
News from Git in Eclipse - EclipseCon EU - 2016-10-26
 
Git journey from mars to neon EclipseCon North America - 2016-03-08
Git journey from mars to neon   EclipseCon North America - 2016-03-08Git journey from mars to neon   EclipseCon North America - 2016-03-08
Git journey from mars to neon EclipseCon North America - 2016-03-08
 
Versioning large binary files with JGit, EGit and Gerrit
Versioning large binary files with JGit, EGit and GerritVersioning large binary files with JGit, EGit and Gerrit
Versioning large binary files with JGit, EGit and Gerrit
 
News from Git in Eclipse - EclipseCon 2015 Europe
News from Git in Eclipse - EclipseCon 2015 EuropeNews from Git in Eclipse - EclipseCon 2015 Europe
News from Git in Eclipse - EclipseCon 2015 Europe
 
Git missiontomars 2015-03-10
Git missiontomars 2015-03-10Git missiontomars 2015-03-10
Git missiontomars 2015-03-10
 
News from EGit - Talk EclipseCon Europe 2014 - Ludwigsburg
News from EGit - Talk EclipseCon Europe 2014 - LudwigsburgNews from EGit - Talk EclipseCon Europe 2014 - Ludwigsburg
News from EGit - Talk EclipseCon Europe 2014 - Ludwigsburg
 
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 9 - starting demo gerrit
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 9 - starting demo gerritGit Tutorial EclipseCon France 2014 - Gerrit Exercise 9 - starting demo gerrit
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 9 - starting demo gerrit
 
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 7 - new changescreen
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 7 - new changescreenGit Tutorial EclipseCon France 2014 - Gerrit Exercise 7 - new changescreen
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 7 - new changescreen
 
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 6 - submit a change
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 6 - submit a changeGit Tutorial EclipseCon France 2014 - Gerrit Exercise 6 - submit a change
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 6 - submit a change
 
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 3 - push change to gerrit
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 3 - push change to gerritGit Tutorial EclipseCon France 2014 - Gerrit Exercise 3 - push change to gerrit
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 3 - push change to gerrit
 
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 2 - fetch the latest state
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 2 - fetch the latest stateGit Tutorial EclipseCon France 2014 - Gerrit Exercise 2 - fetch the latest state
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 2 - fetch the latest state
 
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 1 - configure for gerrit
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 1 - configure for gerritGit Tutorial EclipseCon France 2014 - Gerrit Exercise 1 - configure for gerrit
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 1 - configure for gerrit
 
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 8 - view gerrit review ...
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 8 - view gerrit review ...Git Tutorial EclipseCon France 2014 - Gerrit Exercise 8 - view gerrit review ...
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 8 - view gerrit review ...
 
Git Tutorial EclipseCon France 2014 - Git Exercise 07 - git blame
Git Tutorial EclipseCon France 2014 - Git Exercise 07 - git blameGit Tutorial EclipseCon France 2014 - Git Exercise 07 - git blame
Git Tutorial EclipseCon France 2014 - Git Exercise 07 - git blame
 
Git Tutorial EclipseCon France 2014 - Git Exercise 05 - history view
Git Tutorial EclipseCon France 2014 - Git Exercise 05 - history viewGit Tutorial EclipseCon France 2014 - Git Exercise 05 - history view
Git Tutorial EclipseCon France 2014 - Git Exercise 05 - history view
 
Git Tutorial EclipseCon France 2014 - Git Exercise 01 - installation and conf...
Git Tutorial EclipseCon France 2014 - Git Exercise 01 - installation and conf...Git Tutorial EclipseCon France 2014 - Git Exercise 01 - installation and conf...
Git Tutorial EclipseCon France 2014 - Git Exercise 01 - installation and conf...
 
Code Matters - Eclipse Hackers Git Guide - EclipseCon France 2014
Code Matters - Eclipse Hackers Git Guide - EclipseCon France 2014Code Matters - Eclipse Hackers Git Guide - EclipseCon France 2014
Code Matters - Eclipse Hackers Git Guide - EclipseCon France 2014
 
Interactive Rebase with EGit
Interactive Rebase with EGitInteractive Rebase with EGit
Interactive Rebase with EGit
 
EGit 3.0 and beyond
EGit 3.0 and beyondEGit 3.0 and beyond
EGit 3.0 and beyond
 

Dernier

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 

Dernier (20)

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 

Git Tutorial EclipseCon France 2014 - Git Exercise 03 - work on branches in parallel

  • 1. Work on branches in parallel In this exercise you learn how you can efficiently work in different branches in parallel. A common situation is that you want to switch to another branch and you want to temporarily save your work on the current branch. You will learn two possibilities: ● Amend: Commit an unfinished change and replace this commit later with a new, refined commit using the amend feature of git. ● Stash: Put your change into the git stash area with the stash command Preparation Follow exercise 2, “Develop a feature/bug fix” to create a commit on a feature branch based on the remote tracking branch origin/master. Start working on another feature ● Create a new local branch based on the remote tracking branch “origin/master” ● You may create the new branch from the History View : ○ Select the project, then click Show In > History (Some views, e.g. in the Java EE-Perspective, do not have this shortcut, in this case use Team > Show in History) ○ In the history view click all toggle buttons as shown in the screenshot (“Link with Editor and Selection”, “Show all changes in Repository”, “Compare Mode”, “Show all branches”)
  • 2. ○ Click “Create Branch...” on the commit where“origin/master” points to
  • 3. ● Or you may do that from the Repositories View : select the remote tracking branch origin/master and click Create Branch ● Enter “addMultiplyOperation” as the name of the new branch, make sure the “Checkout new branch” is selected and click Finish ● Check that now you don’t see the changes of the first exercise anymore in your workspace. ● Start working on a change, e.g. add a MultiplyOperation, do not commit yet, first read on. Save your work temporarily Now you want to switch to another branch but you want to continue working at your new feature later on. There are two ways to achieve that: doing a preliminary commit and use amend later to continue your work or use stash. You may do this exercise twice to try both ways. Preliminary Commit The easiest thing to do is to just commit your work in progress and amend that commit later to replace the preliminary commit. ● Open the Git Staging View ● Enter a preliminary message, e.g. “WIP ...” for Work in Progress, stage the files to be committed and click on Commit
  • 4. Stash Select Stash Changes on the repository node in the Git Repositories View. As a result you will get a new node in the view. It contains a list of all the stashed changes. The label contains the current branch, the id and the commit message of the current commit. Note that untracked files are not stashed by default. If you are using at least EGit 3.4 you can include untracked files by checking the corresponding option. In older versions you have to drag and drop an untracked file to the “Staged Changes” area before you can stash it. Switch to another branch ● Now you can switch to the first feature branch “addDivideOperation”, either by double clicking on the branch node in the Git Repositories View, by selecting “Team > Switch to > addDivideOperation” or by clicking “Checkout” in the History View. ● Check that your workspace contains the changes you committed in your first feature (implementing divide) branch. You could now continue working here. For example: you may want to fix the division by zero issue if it is not already handled. If you do any changes in the “addDivideOperation” branch don’t forget to commit them before the next step
  • 5. ● Switch back to the “addMultiplyOperation” branch Continue working on the branch to add Multiply Case 1: Preliminary Commit ● Do another change in the workspace improving Multiply. ● Compare your changed project with the first, preliminary commit by selecting Compare With > HEAD revision. This will show you the changes you will add on top of the first commit. ● Compare your changed project with the parent commit of your first, preliminary commit by selecting Compare With > Previous revision. This will show you the changes you will have in your new commit after the next step. Create a new commit with the combined changes of your first, preliminary commit and your current changes ● Open the Git Staging View ● Click the “Amend” button as shown below. ● Now you see again the commit message of the last commit you made in this branch. Change it to something meaningful, stage the change and click the Commit button. ● In the History View you can now see that your first, preliminary commit was replaced by the new one.
  • 6. Case 2: Stash ● In the Repositories View, select Apply Stashed Changes on the stash entry. ● Note that you can apply the stashed change on any commit in your repository. This is useful if you have started on a branch but you realize that you would like to continue on another branch. If you apply the stashed commit on another base version this may lead to conflicts you may have to resolve in this case. Copyright © 2014 by C. Halstrick, E. Kempin, S. Lay, S. Zivkov, M. Sohn