noresm:gitbestpractice

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
noresm:gitbestpractice [2015-11-16 09:47:33]
alfg
noresm:gitbestpractice [2022-05-31 09:29:32] (current)
Line 1: Line 1:
 ====Obtain a copy of the model (using git)==== ====Obtain a copy of the model (using git)====
  
-First: Visit this page: https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup+  
 +  - **Create a github user:** You can create the github user yourself. Go to https://github.com/join and create a user (Make user-name which is easy to understand, for example FirstnameLastname. You can attach several email-addresses to the same user.) 
 +  - Visit this page: https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup 
 +  - Send email to oyvind.seland@met.no to get the right permissions for the new github user (The email must contain who you are and the github username). 
 +  - When you have the right permissions, you can obtain the code. 
 +  - git clone https://githubUserName@github.com/metno/noresm.git 
  
-Then use the command <file>git clone https://githubUserName@github.com/metno/noresm.git </file>  If you get error messages, verify that you can open the page https://github.com/metno/noresm in a web-browser. If you can not, you are probably not a github-user or not member of the noresm group on github. Send email to alf.grini@met.no (with a copy to trond.iversen@met.no) to get the right permissions. You can create the github user yourself. Go to https://github.com/join and create a user. Make user-name which is easy to understand, for example FirstnameLastname. You can attach several email-addresses to the same user.+The last point will create a new directory called "noresm" in the place you checked out the model. Go to that directory before executing any git-commands.
  
-**More advanced:** To make life easier and avoid typing passwords all the timefollow the recipe here:  https://help.github.com/articles/generating-ssh-keys/. If you are still asked for passwords about your id_rsh.pub file, it is the password to log in to the machine where that file is stored which is needed. Using this procedure, you can clone with <file> git clone git@github.com:metno/noresm.git </file>+If you get error messagesverify that you can open the page https://github.com/metno/noresm in a web-browser. If you can not, you are probably not a github-user or not member of the noresm group on github. 
 + 
 +**Also do the following on all machines where you use git:** 
 +  * **Make sure you have a version of git >= 2.0** (add the line "module load git" to your .bashrc files on hexagon, vilje) 
 +  * **git config - -global push.default simple** (Will edit your ~/.gitconfig file to a safer way to share your modifications, see http://stackoverflow.com/questions/13148066/warning-push-default-is-unset-its-implicit-value-is-changing-in-git-2-0)
  
 Note that with git, the main branch is no longer called "trunk", it is called "master"! Note that with git, the main branch is no longer called "trunk", it is called "master"!
Line 15: Line 24:
 Check that your favourite branch is available using the command  Check that your favourite branch is available using the command 
 <file>git branch --all</file> <file>git branch --all</file>
 +(You should see the branch "master" on top with a star next to it. This is the branch you get by default. The other branches are listed below with remotes/origin/branchName, but you can not work on them until you check them out, see below)
  
 To check out (locally) your favourite branch and to start working on it, write To check out (locally) your favourite branch and to start working on it, write
Line 25: Line 35:
 Note that once a branch has been checked out using the -b option, you can switch between any of your checked out branches using the command Note that once a branch has been checked out using the -b option, you can switch between any of your checked out branches using the command
 <file>git checkout aCheckedOutBranchName</file> <file>git checkout aCheckedOutBranchName</file>
 +
 +Note that in git, switching to a new branch change the files in your working directory. Git will warn you if you have any modified files before switching to a new branch. This is different from how svn works.
  
 ====Modify files ==== ====Modify files ====
  
 Modify the code (for example a file named myChangedFile.F90) and send back to your local repository through Modify the code (for example a file named myChangedFile.F90) and send back to your local repository through
-<file>git add myCHangedFile.F90 </file>+<file>git add myChangedFile.F90 </file>
 <file>git commit -m "aMessage" </file> <file>git commit -m "aMessage" </file>
  
-The message should link to the issue on github, so if you fix issue number 100 by this code change, you would probably write something like <file>git commit -am "Did part of the work to resolve #100" </file>+The message should link to the issue on github, so if you fix issue number 100 by this code change, you would probably write something like <file>git commit -am "Did part of the work to resolve metno/noresm#100" </file>
  
 Verify, using the tool "gitk" that the changes make sense. Verify, using the tool "gitk" that the changes make sense.
Line 50: Line 62:
  
 You can also do (to be completely sure): You can also do (to be completely sure):
-<file>git push remoteName myLocalBranchName:remoteBranchName </file> which if your are changing the master-branch would translate to <file>git push origin master:master </file> (The above command means push my changes to the remote named "origin" from my local branch named master to the remote branch named master. If you are changing another branch than master, you must obviously not write "master".+<file>git push remoteName myLocalBranchName:remoteBranchName </file> which if your are changing the master-branch would translate to <file>git push origin master:master </file> (The above command means push my changes to the remote named "origin" from my local branch named master to the remote branch named master. If you are changing another branch than master, you must obviously not write "master".)
  
 ====If you don't understand and want to get back to svn ==== ====If you don't understand and want to get back to svn ====
  • noresm/gitbestpractice.1447667253.txt.gz
  • Last modified: 2022-05-31 09:23:24
  • (external edit)