GitHub
LCOGT/lcogtsnpipe
Supernova
<user>/lcogtsnpipe
Supernova
/supernova/git/lcogtsnpipe
Your Workstation
<user>/lcogtsnpipe
GitHub
LCOGT/lcogtsnpipe
Your Workstation
<user>/lcogtsnpipe
Developing a New Feature
-
If repository does not exist:
-
git clone git@github.com:LCOGT/lcogtsnpipe.git
-
- cd to lcogtsnpipe directory
"origin"
clone
GitHub
LCOGT/lcogtsnpipe
Your Workstation
<user>/lcogtsnpipe
Access your local copy
-
If repository does not exist:
-
git clone git@github.com:LCOGT/lcogtsnpipe.git
-
- cd to lcogtsnpipe directory
-
Check that you are on the master* branch
-
git branch
-
-
Check that when you say "origin" your repository points to LCOGT/lcosnpipe on GitHub
-
git remote -v
-
* More recent repositories have changed the default branch from master to main
"origin"
master
master
GitHub
LCOGT/lcogtsnpipe
Your Workstation
<user>/lcogtsnpipe
Make a Clean Start
-
If repository does not exist:
-
git clone git@github.com:LCOGT/lcogtsnpipe.git
-
- cd to lcogtsnpipe directory
-
Check that you are on the master* branch
-
git branch
-
-
Check that when you say "origin" your repository points to LCOGT/lcosnpipe on GitHub
-
git remote -v
-
-
Make sure your master branch is up to date with LCOGT/lcosnpipe on GitHub
-
git pull origin master
-
fetch the master branch from origin
-
merge the master branch from origin into your current branch (which we checked was master)
-
* More recent repositories have changed the default branch from master to main
"origin"
master
master
origin/master
fetch
merge
GitHub
LCOGT/lcogtsnpipe
Your Workstation
<user>/lcogtsnpipe
Branching
- Create a copy of the master branch
-
git branch new_feature
- copies all files that have been committed at least once
-
- Check that the new branch was created:
-
git branch
-
- Switch to new branch
-
git checkout new_feature
-
- Check you are on the new_feature branch
-
git branch
-
master
new_features
c1m
c2m
c3m
c3m=c1nf
merge
GitHub
LCOGT/lcogtsnpipe
Your Workstation
<user>/lcogtsnpipe
Developing Your New Feature
- Modify code on new_feature branch
- Save changes incrementally to new_feature branch
- check you are on the new_feature branch
-
git branch
-
- Save changes:
-
git add <modified_filename>
-
git commit -m "commit message"
-
- check you are on the new_feature branch
master
new_features
c1m
c2m
c3m
c3m=c1nf
c2nf
c3nf
add commmit
GitHub
LCOGT/lcogtsnpipe
Your Workstation
<user>/lcogtsnpipe
Updating Your Branch
- Update your branch with the latest master branch
-
git checkout master
-
git pull origin master
-
git checkout new_feature
-
git merge master
- Merge and pull always merge into your current branch
-
master
new_features
c1m
c2m
c3m
c3m=c1nf
c2nf
c3nf
c4m=c8gh+c3m
c8gh
git pull
c4nf=c4m+c3nf
merge
master
GitHub
LCOGT/lcogtsnpipe
Your Workstation
<user>/lcogtsnpipe
Testing your code
- Test your new code as it will run on production
- create a new conda test env
- switch to new test env
- delete the build directory in lcogtsnpipe
- run python setup.py install
- you new have the new pipeline running in your test env
master
new_features
c1m
c2m
c3m
c3m=c1nf
c2nf
c3nf
c4m=c8gh+c3m
c8gh
git pull
c4nf=c4m+c3nf
merge
master
GitHub
LCOGT/lcogtsnpipe
Your Workstation
<user>/lcogtsnpipe
Push your code to GitHub
- Push your branch (new_feature) to create a new branch on GitHub that is an identical copy
-
git push -u origin new_feature
-
master
new_features
c1m
c2m
c3m
c3m=c1nf
c2nf
c3nf
c4m=c8gh+c3m
c8gh
git pull
c4nf=c4m+c3nf
merge
master
GitHub
LCOGT/lcogtsnpipe
Creating a Pull Request
On GitHub:
- Compare and Pull Request:
- Check changes:
- look at commits
- look at files changed
- check actual changes
- check branches:
- LCOGT/lcogtsnpipe/new_features into LCOGT/lcogtsnpipe/master
- Create Pull Request
c8gh
master
new_feature
c4nf
Let's try it
- clone: https://github.com/abostroem/code_review_LCO-2024
- Create a branch (make it unique - not just new_feature)
- make a change
- Create a Pull Request
Testing a PR
PR from LCOGT/lcosnpipe
- git fetch origin
- git checkout BRANCH_NAME
- create test conda env
- python setup.py install
- test
GitHub
LCOGT/
lcosnpipe
Megan
LCOGT/
lcosnpipe
Supernova
user/
lcosnpipe
make branch
change code
push to GitHub (create remote branch)
1.
fetch remote branch
checkout remote branch
install
test
Open PR
merge PR
2.
3.
4.
PR from fork with diff branch name
- git fetch origin pull/ID/head:BRANCH_NAME
- git checkout BRANCH_NAME
- create test conda env
- python setup.py install
- test
GitHub
LCOGT/
lcosnpipe
Megan
drmegan/
lcosnpipe
Supernova
LCOGT/
lcosnpipe
make branch
change code
push to GitHub (create remote branch)
1.
fetch remote branch
checkout remote branch
install
test
Open PR
merge PR
2.
3.
4.
GitHub
drmegan/
lcosnpipe
* this has the advantage of not having to add a remote
PR from fork w/ diff branch name
- git remote add ALIAS THEIR_REPO_URL
- git fetch ALIAS
- git checkout PR_BRANCH
- create test conda env
- ...
GitHub
LCOGT/
lcosnpipe
Megan
drmegan/
lcosnpipe
Supernova
LCOGT/
lcosnpipe
make branch
change code
push to GitHub (create remote branch)
1.
fetch remote branch
checkout remote branch
install
test
Open PR
merge PR
2.
3.
4.
GitHub
drmegan/
lcosnpipe
* this has the advantage of being able to incorporate changes
PR from fork w/ same branch name
- git remote add ALIAS THEIR_REPO_URL
- git fetch ALIAS
- git checkout -b LOCAL_BRANCH ALIAS/PR_BRANCH
- create test conda env
- ...
GitHub
LCOGT/
lcosnpipe
Megan
drmegan/
lcosnpipe
Supernova
LCOGT/
lcosnpipe
make branch
change code
push to GitHub (create remote branch)
1.
fetch remote branch
checkout remote branch
install
test
Open PR
merge PR
2.
3.
4.
GitHub
drmegan/
lcosnpipe
LCO-training
By abostroem
LCO-training
- 138