Git
Between ROOT Trees, Git Branches and Random Forest classifiers, I miss becoming a park ranger.
Last updated
Was this helpful?
Between ROOT Trees, Git Branches and Random Forest classifiers, I miss becoming a park ranger.
Last updated
Was this helpful?
Git is a version control software, used currently for all programming projects. All information about Git can be inferred at this free book:
Therefore, here I will just report some notes on the commands I use more frequently:
Simply use
git clone repolink
it will create a folder with the same name of the repository (you can add a different name as second argument if you wish)
It is a good practice to have a check of our changes, before committing them. We can do it with
git diff
or better (GUI-based)
git difftool
(I usually choose "meld" as difftool software, but it is a matter of taste)
For jupyter notebooks:
git difftool --tool=nbdime
When you are ready to commit your changes, just do:
git add filename
git commit -m 'commit message'
Multiple files can be added in the same commit. It is often useful to group the files related to the same change.
Until you push them to an online repository (GitHub, GitLab...) they will be only in your local computer.
Always first pull your repository (even if you think there are no changes, it does not hurt to check)
git pull
Then you can launch the push
git push
If you get security errors, such as:
Permission denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists
You probably need to set a SSH keys on your github account (from settings).
Create ssh key according to the guide https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent, and activate it on your machine. Then copy the line from the file into the github account page
branches are quite complicated to use, so it is better to refer to the guide for details. But in general I need to create my branch
git checkout -b newbranch
move to an existing branch
git checkout mybranch
and merge (or rebase, with only difference the chronology of changes) some branches with each other
git merge other branch
Finally, I need to delete branches I do not use anymore:
git branch -d oldbranch
Rebase it is similar to merge, but it applies your commits over the source commits. It may be recommended if you want the commit history to be more clear.
So you can git rebase origin/master to apply your commits over them :)
For more information: https://git-scm.com/docs/git-rebase
Note, you will need to force push due to the changed history. Please do it as the last step, because it makes pull requests harder to review!
Git command cherry-pick allows to apply only one commit to the code. The commit can come from whichever branch, and it can be identified with git log.
Example:
git cherry-pick 02e641bd62b6efe1924eb008413f2e57f4e9a996
Be careful that this does not cause conflict with your master branch
GitHub actions automate code options, for instance at every pull
Did it for Doxygen reference of sndsw, following indications by Oliver and over here:
gh-pages is a branch that can be published as the page, for example:
connects to the gh-pages branch of my FairShip repository
Interface between git and svn
Used to interface FEDRA with SNDDIST.
Followed guide here:
https://gist.github.com/rickyah/7bc2de953ce42ba07116
For now, just commit to svn and pass to git when needed. Local git changes (install.sh, etc. for now will remain on git). Need to test svn passage
Basically, update git with svn changes by using git svn rebase.
You can also send commits to svn, but I would not do that (permissions?) git svn dcommit
Need to solve merges, it will always replicates the same commits