User Tools

Site Tools


devs:usegit

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
devs:usegit [2022/04/05 16:33]
helene [2.4 Merging]
devs:usegit [2022/04/05 16:40] (current)
helene
Line 69: Line 69:
 === 2.3.2 Committing a part of your changes === === 2.3.2 Committing a part of your changes ===
 Example: I modified the subroutine CHAB.F to correct some calculation,​ and I deleted useless comments in CHABDAM.F. These are two different changes that should be committed separately. In a first time, I am only going to commit the changes made in CHABDAM.F by using the '​indexing'​ function. Only the changes made to the indexed routines will be taken into account in the commit (see <imgref image9>​). Example: I modified the subroutine CHAB.F to correct some calculation,​ and I deleted useless comments in CHABDAM.F. These are two different changes that should be committed separately. In a first time, I am only going to commit the changes made in CHABDAM.F by using the '​indexing'​ function. Only the changes made to the indexed routines will be taken into account in the commit (see <imgref image9>​).
 +
 <​imgcaption image9|>​{{ :​devs:​commit2.png?​nolink&​600 |}}</​imgcaption>​ <​imgcaption image9|>​{{ :​devs:​commit2.png?​nolink&​600 |}}</​imgcaption>​
  
Line 78: Line 79:
   * Reset and delete changes (--hard)   * Reset and delete changes (--hard)
 __Example__:​ I committed changes on CALMAT2 but I want to change my commit message. In <imgref image10>,​ you can view the history of the branch. The red arrow  « origin/​Helene »  indicates the last commit made on the distant branch. The arrow « Helene » indicates the last commit made on my local branch. My local branch is one commit ahead of the server. __Example__:​ I committed changes on CALMAT2 but I want to change my commit message. In <imgref image10>,​ you can view the history of the branch. The red arrow  « origin/​Helene »  indicates the last commit made on the distant branch. The arrow « Helene » indicates the last commit made on my local branch. My local branch is one commit ahead of the server.
 +
 <​imgcaption image10|>​{{ :​devs:​commit3.png?​nolink&​600 |}}</​imgcaption>​ <​imgcaption image10|>​{{ :​devs:​commit3.png?​nolink&​600 |}}</​imgcaption>​
 To reset my local branch and delete the last commit, I can right-click on the last commit of the server (here commit 6697b587 « ILAW=21 ; Lecture theta – IVAL 21 »), and select « Reset » and then chose between keeping or deleting changes. In my case, since I only want to change the commit message, I keep the changes so I can commit them again afterwards. \\ To reset my local branch and delete the last commit, I can right-click on the last commit of the server (here commit 6697b587 « ILAW=21 ; Lecture theta – IVAL 21 »), and select « Reset » and then chose between keeping or deleting changes. In my case, since I only want to change the commit message, I keep the changes so I can commit them again afterwards. \\
Line 93: Line 95:
 You can now merge your branch with the master. Set your branch as the active branch and select “Manage branches”. Right-click on your branch and choose “Merge from…”. In the Team Explorer tab, you will see a drop-down list from which you can select which branch you want to merge from. Select “origin/​master” – it is the distant master branch. Remark: if you pulled the changes in your local master branch, selecting “master” or “origin/​master” should be the same. \\ You can now merge your branch with the master. Set your branch as the active branch and select “Manage branches”. Right-click on your branch and choose “Merge from…”. In the Team Explorer tab, you will see a drop-down list from which you can select which branch you want to merge from. Select “origin/​master” – it is the distant master branch. Remark: if you pulled the changes in your local master branch, selecting “master” or “origin/​master” should be the same. \\
 You can now click on “merge”. ​ You can now click on “merge”. ​
-{{ :​devs:​merge1.png?​nolink&​700 |}}+<​imgcaption image11|>​{{ :​devs:​merge1.png?​nolink&​700 |}}</​imgcaption>​
 Merging the master branch into your branch should be done regularly to keep your version up to date. In particular, you must merge __before__ you make changes in a global subroutine (such as ELEMB, LOI2, LAMIN2, PRISIG, PRISUM, …) in order to avoid conflicts between the master and your branch. ​ Merging the master branch into your branch should be done regularly to keep your version up to date. In particular, you must merge __before__ you make changes in a global subroutine (such as ELEMB, LOI2, LAMIN2, PRISIG, PRISUM, …) in order to avoid conflicts between the master and your branch. ​
  
-=== Merge conflicts ===+=== 2.4.2 Merge conflicts ===
 Example of a merge conflict : Example of a merge conflict :
   * The developper 1 added a call to a new law in LOI2 and merged his branch into the master branch;   * The developper 1 added a call to a new law in LOI2 and merged his branch into the master branch;
Line 106: Line 108:
 Generally, the 2 last options are not very useful. Indeed, if you consider the example above, this would mean deleting either the call to my law or the call to the law of developer 1. What we want here is a version with call to both laws. \\ Generally, the 2 last options are not very useful. Indeed, if you consider the example above, this would mean deleting either the call to my law or the call to the law of developer 1. What we want here is a version with call to both laws. \\
 \\ \\
-By selecting the “Merge” option, you can create a new version of the source file in conflict by selecting which lines you want to keep. In <​imgref ​image11> for instance, I combined 2 versions that each had a different comment written on the same line. I wanted to keep both comments, so I selected both (the on in the master version and the one in Dev2 version). A new version of the file is generated by visual studio. Once you are satisfied with the new version, you can save it and click on « Accept merge » in the top left corner. The merge can then be made without conflict.+By selecting the “Merge” option, you can create a new version of the source file in conflict by selecting which lines you want to keep. In <​imgref ​image12> for instance, I combined 2 versions that each had a different comment written on the same line. I wanted to keep both comments, so I selected both (the on in the master version and the one in Dev2 version). A new version of the file is generated by visual studio. Once you are satisfied with the new version, you can save it and click on « Accept merge » in the top left corner. The merge can then be made without conflict. 
 + 
 +<​imgcaption image12|>​{{ :​devs:​merge2.png?​nolink&​600 |}}</​imgcaption>​ 
 + 
 +=== 2.4.3 Merging your changes into the master === 
 +The Master branch is a protected branch, therefore merging into it can only be done on the GitLab website. \\ 
 +In order to make a merge with GitLab – that is, to put the modification from your branch into the official version of the code (master branch) – it is advised to first merge the master branch into your branch using Visual Studio (see section 2.4.2) to solve potential merge conflicts. \\ 
 +\\ 
 +To make the merge in GitLab, go to the Lagamine page ⟶ Repository ⟶ Branches. \\ 
 +\\ 
 +You can then click the « Merge request » button corresponding to your branch. You will then have to input a title for the merge (as done for the commits). 
 + 
 +===== 3 Useful links ===== 
 +  * Documentation on how to use Git in Visual Studio: https://​docs.microsoft.com/​en-us/​azure/​devops/​repos/​git/​gitquickstart?​view=azure-devops&​tabs=visual-studio-2019 
 +  * GitLab documentation:​ https://​docs.gitlab.com/​ee/​index.html 
 + 
 + 
  
-<​imgcaption image11|>​{{ :​devs:​merge2.png?​nolink&​600 |}}</​imgcaption>​ 
  
devs/usegit.1649169237.txt.gz · Last modified: 2022/04/05 16:33 by helene