Difference between revisions of "Getting Started - Git"
Line 1: | Line 1: | ||
+ | =='''Version Control'''== | ||
+ | ===Hierarchy=== | ||
+ | * Git is used as version control for all shared code | ||
+ | * Casey (https://github.com/mrcmor100) has forked from all relevant JeffersonLab (https://github.com/JeffersonLab) repositories | ||
+ | ** All XEM group members other than Casey only need to worry about changes to Casey's repositories. | ||
+ | ** Casey is in charge of pulling changes from the JeffersonLab repositories. | ||
+ | *All XEM group members will 'Fork' Casey's repository, which will appear on their GitHub account, that is your 'origin'. | ||
+ | **Changes can be made on a 'local' branch and then pushed to your 'origin'. | ||
+ | **Once you have pushed your changes to your 'origin', you can make a pull request to Casey add your changes into 'upstream'. | ||
+ | *Communications about new features / calibrations / etc will be sent via the Software Slack channel. Feel free to also watch Casey's repositories for email notifications. | ||
+ | |||
+ | '''Remember:''' The point of this scheme is for us to <font size="+0.25"><font color="Black">'''Collaborate'''</font></font>! We can independently work on different calibrations / scripts / etc and bring all of our changes together to spread out the workload. | ||
+ | |||
+ | ===Hierarchy Visualization=== | ||
+ | [[Image:Git_Collab.jpg]] | ||
+ | |||
+ | ===Setting SSH for GitHub at JLab=== | ||
+ | #Generate ssh key if you do not have one. | ||
+ | ##ssh-keygen (when prompted for file in which to save the key and pass phrase, just hit return ) | ||
+ | #Put ssh public key on Github | ||
+ | ## Open "Settings" from the pull down menu in the top right. | ||
+ | ## Go to "SSH and GPG keys" | ||
+ | ## Click on "new ssh key" button. At terminal type "more ~/.ssh/id_rsa.pub". Copy the code and paste into github. | ||
+ | #*Note: The ssh key may not work right away. If this happens, just log off from the iFarm machine and wait a few minutes for the key to start working. You may be unable to login to the iFarm for a few minutes, this is OK. Once you are able to login to the iFarm again the ssh key should be working, so you should be able to start cloning remote repositories. | ||
+ | |||
+ | == Headline text == | ||
+ | |||
+ | |||
==Common Git Commands Used== | ==Common Git Commands Used== | ||
Revision as of 17:00, 28 February 2023
Version Control
Hierarchy
- Git is used as version control for all shared code
- Casey (https://github.com/mrcmor100) has forked from all relevant JeffersonLab (https://github.com/JeffersonLab) repositories
- All XEM group members other than Casey only need to worry about changes to Casey's repositories.
- Casey is in charge of pulling changes from the JeffersonLab repositories.
- All XEM group members will 'Fork' Casey's repository, which will appear on their GitHub account, that is your 'origin'.
- Changes can be made on a 'local' branch and then pushed to your 'origin'.
- Once you have pushed your changes to your 'origin', you can make a pull request to Casey add your changes into 'upstream'.
- Communications about new features / calibrations / etc will be sent via the Software Slack channel. Feel free to also watch Casey's repositories for email notifications.
Remember: The point of this scheme is for us to Collaborate! We can independently work on different calibrations / scripts / etc and bring all of our changes together to spread out the workload.
Hierarchy Visualization
Setting SSH for GitHub at JLab
- Generate ssh key if you do not have one.
- ssh-keygen (when prompted for file in which to save the key and pass phrase, just hit return )
- Put ssh public key on Github
- Open "Settings" from the pull down menu in the top right.
- Go to "SSH and GPG keys"
- Click on "new ssh key" button. At terminal type "more ~/.ssh/id_rsa.pub". Copy the code and paste into github.
- Note: The ssh key may not work right away. If this happens, just log off from the iFarm machine and wait a few minutes for the key to start working. You may be unable to login to the iFarm for a few minutes, this is OK. Once you are able to login to the iFarm again the ssh key should be working, so you should be able to start cloning remote repositories.
Headline text
Common Git Commands Used
Used before, complicated
Lets say Casey added a branch to hallc_replay_XEM that you'd like to use. We want to put that on our origin, but the fetch upstream button on github does not add the new branch to your origin. To do this we must:
First ensure you are tracking the remote upstream:
git remote -v
Lists all names of remote repositories and the path to them
git remote add upstream git@github.com/mrcmor100/hallc_replay_XEM.git
Now that we told our local where upstream is, we can track the new branch in our local:
git checkout upstream_branch_name
You could alternatively name this whatever you'd like (don't)
git pull upstream upstream_branch_name
Pulls from upstream to local
git push origin local_branch_name
local_branch_name should match upstream_branch_name!
Great, now you have the upstream branch on your origin.
Thing to check
If Casey updates upstream_branch_name, will there be a fetch upstream option for that branch?
Lets say we want to stop tracking old branches that no longer exist:
git remote prune origin
That'll do it for ya'!
Reset Repo (go back a commit)
Working With Git Submodules
I found this to be a very good resource that covers git submodules with simple examples.