noresm:gitbestpractice

This is an old revision of the document!


First: Visit this page: https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup

Then use the command

 git clone git@github.com:metno/noresm.git 

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.

To make life easier and avoid typing passwords all the time, follow the recipe here: https://help.github.com/articles/generating-ssh-keys/

When you have cloned the model, check that you have gotten what you wanted!

Check that your favourite branch is available using the command

git branch --all

To check out (locally) your favourite branch and to start working on it, write

git checkout -b myBranchName origin/myBranchName 

(Note that myBranchName must be one of the branches listed by the above command)

If you don't user the “-b” option, you will get something which is not correct. Make sure you are tracking a remote branch. You can write

git branch -vv

to see which remote branch you are tracking. The output will be something like:

* myCheckedOutBranchName 1a08184 [origin/myCheckedOutBranchname] LatestCommitMessageOnBranch

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

git checkout aCheckedOutBranchName

Modify the code (for example a file named myChangedFile.F90) and send back to your local repository through

git add myCHangedFile.F90 
git commit -m "aMessage" 

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

git commit -am "Did part of the work to resolve #100" 

Verify, using the tool “gitk” that the changes make sense.

git pull 

To be absolutely sure about branch names etc, you can do

git pull remoteName remoteBranchName:myLocalBranchName 

which if your are picking up changes the master-branch would translate to

git pull origin master:master 

This command assumes that your changes go to the remote branch named like your branch (which is most of the times the case)

git push 

You can also do (to be completely sure):

git push remoteName myLocalBranchName:remoteBranchName 

which if your are changing the master-branch would translate to

git push origin master:master 

(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”.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • noresm/gitbestpractice.1447654351.txt.gz
  • Last modified: 2022-05-31 09:23:24
  • (external edit)