Git repository
From the [official Github website]:
GitHub is a cloud-based platform where you can store, share, and work together with others to write code.
Storing your code in a "repository" on GitHub allows you to:
- Showcase or share your work.
- Track and manage changes to your code over time.
- Let others review your code, and make suggestions to improve it.
- Collaborate on a shared project, without worrying that your changes will impact the work of your collaborators before you're ready to integrate them.
- Collaborative working, one of GitHub’s fundamental features, is made possible by the open-source software, Git, upon which GitHub is built.
The LHEP Github is the place where the repos should be stored in order to be accessible throughout LHEP members. It is a very good practice to work from repos, as cited, this helps keeping track of your work and allow others to easily use it.
Getting access to LHEP Github
If you aren't a member yet, (once you have an account) contact an owner (e.g. [Serhan] or [Nicolas]) to get added. Then you will be able to create your repository or use an already existing one.
Cloning the repo on a local machine
The remote github acts as the main repository. You can clone this repository on local machine which allows you to work on it. Once your work done, you can push your work from your local to the remote repo, such that it is saved in the cloud and other people can access it. On the other way around, if somebody else pushed something from their local repo to the remote one, then you can pull the changes from the remote repo to your local one such that you can use the work from others.
To clone a repo, first you will have to 'link' your machine to the remote repo. An easy way to do this is to set up an ssh key pair on your local machine and register it on github, follow this tutorial, under generate a new ssh key. Note that if you want to clone many repo on the same machine, you will have to generate one key per repo. If you do not want to add your ssh key to your agent everytime you connect to your machine, you can add the following commands in the .bashrc or .bash_profile:
# Run the ssh-agent if not running yet # Function to start a new agent and save its info # from https://docs.vscentrum.be/accounts/ssh_agent.html start-ssh-agent() { # # Start an ssh agent if none is running already. # * First we try to connect to one via SSH_AUTH_SOCK # * If that doesn't work out, we try via the file ssh-agent-environment # * And if that doesn't work out either, we just start a fresh one and write # the information about it to ssh-agent-environment for future use. # # We don't really test for a correct value of SSH_AGENT_PID as the only # consequence of not having it set seems to be that one cannot kill # the ssh-agent with ssh-agent -k. But starting another one wouldn't # help to clean up the old one anyway. # # Note: ssh-add return codes: # 0 = success, # 1 = specified command fails (e.g., no keys with ssh-add -l) # 2 = unable to contact the authentication agent # sshfile=~/.ssh/ssh-agent-env # # First effort: Via SSH_AUTH_SOCK/SSH_AGENT_PID # if [ -n "$SSH_AUTH_SOCK" ]; then # SSH_AUTH_SOCK is defined, so try to connect to the authentication agent # it should point to. If it succeeds, reset newsshagent. ssh-add -l &>/dev/null if [[ $? != 2 ]]; then echo "SSH agent already running." unset sshfile return 0 else echo "Could not contact the ssh-agent pointed at by SSH_AUTH_SOCK, trying more..." fi fi # # Second effort: If we're still looking for an ssh-agent, try via $sshfile # if [ -e "$sshfile" ]; then # Load the environment given in $sshfile . $sshfile &>/dev/null # Try to contact the ssh-agent ssh-add -l &>/dev/null if [[ $? != 2 ]]; then echo "SSH agent already running; reconfigured the environment." unset sshfile return 0 else echo "Could not contact the ssh-agent pointed at by $sshfile." fi fi # # And if we haven't found a working one, start a new one... # #Create a new ssh-agent echo "Creating new SSH agent." ssh-agent -s > $sshfile && . $sshfile unset sshfile } # Start the ssh-agent start-ssh-agent #&>/dev/null # Add the key ssh-add ~/.ssh/id_ed25519_your_ssh_key0 &>/dev/null ssh-add ~/.ssh/id_ed25519_your_ssh_key1 &>/dev/null
Once your key is set up, you are ready to clone the repo on your local machine. See the following screenshot for the number references
- Click on the expandable green clone button
- Select ssh
- Copy the repo link
Note that if you have many repos on the same machine you will have to use an alias host instead of github.com and register it in a config file as described here.
Finally go on your local machine and use the git clone command:
<code> git clone git@github.com:LHEP-neutrino/<your_repo>.git </code>
You are ready to go and do your super important work that now can be easily saved! Don't forget to pick the good manners like working on a branch, pulling the remote regularly to get the latest changes and pushing your work regularly to save it on the remote repo, and so on. You can find plenty of tutorials on basic uses or advances uses (like issue report, version release, CI/CO pipeline integration, ...), don't hesitate to ameliorate the LHEP github :).