Omega - Advanced Data Structures and Algorithms
- The inspiration behind this project is to improve our programming skills and also help others new to programming to pick up while studing this course in team sport and collabration fashion because the best way to learn programming is through algorithms.
- Would love to accept your patches and contributions to the Programming aspect of the course.
- To contribute, use fork and branch workflow.
Also know as Fork-and-Branch Workflow
Uses three repos:
- Original repository (remote) - An open source repo on GitHub
- Forked repository (remote) - my forked copy of the open source repo on Github
- Cloned (local) repository (from Forked) - my local copy of my forked repo
- Fork a GitHub repository
- Clone the forked repository to your local system.
- Add a Git remote for the original repository.
- Create a feature branch in which to place your changes.
- Make your changes to the new branch.
- Commit the changes to the branch.
- Push the branch to GitHub.
- Open a pull request from the new branch to the original repo.
- Clean up after your pull request is merged.
-
Fork a repo
- Click the fork icon in the upper right hand corner of your favorite repository.
-
Clone to desktop from forked repo
# Use favorite desktop client or do from command line git clone https://github.com/GODINME/Omega.git
-
Add upstream remote pointing back to the original repo
# By convention this remote is named "upstream" git remote add upstream https://github.com/GODINME/Omega.git
-
Sync cloned fork with upstream repo
# fetch from upstream remote git fetch upstream # view all branches including local ones that represent remote ones git branch -va # checkout main git checkout main # merge upstream (again, this is merging two local branches) git merge upstream/main
-
Create feature branch
# new branch should be based off of main git checkout main # make it a simple, descriptive name & switch to it git branch newfeature git checkout newfeatue # ALTERNATE OPTION # combine previous two lines into one command if desired git checkout -b "newfeature"
-
Develop, test, and commit changes to feature branch
# commit 1 git commit -m "Add xyz" # commit 2 git commit -m "Update xyz" # commit 3 git commit -m "Expand xyz functionality"
-
CLEAN-UP BRANCH BEFORE PULL REQUEST
If any commits have been made to the upstream master branch, you should rebase your feature branch so that merging it will be a simple fast-forward that won't require any conflict resolution work.
-
Fetch upstream master & merge
# Fetch upstream master and merge with your repo's master branch git fetch upstream git checkout master git merge upstream/main
-
Rebase feature branch onto updated main
# If there were any new commits, rebase your feature branch onto updated master git checkout newfeature git rebase main
-
Now, it may be desirable to squash some of your smaller commits down into a small number of larger more cohesive commits. You can do this with an interactive rebase:
# Rebase all commits on your feature branch git checkout git rebase -i main
See the Interactive Rebasing section of Atlassian's Merging vs. Rebasing Tutorial
See GitHub Help About Git rebase for a walkthrough on how to use
git rebase -i
-
-
Push changes to GitHub
# Pushes feature branch to GitHub git push origin newfeature
-
Initiate a Pull Request from feature branch
- Go to forked repo on GitHub
- Select feature branch
- Click the Pull Request button
-
CLEAN-UP REPOS AFTER INTEGRATION
Once maintainer accepts and merges changes into original repositry
-
Update local clone (git pull upstream main) - This brings down the updated main branch that includes your new developoment changes and merges it with local main
# Checkout main git checkout main # Fetch upstream main and merge with local repo's main branch git fetch upstream git merge upstream/main # ALTERNATE OPTION # Update local clone (pull does a fetch & merge) git pull upstream main
-
We can now delete the feature branch since changes are already in main branch
# delete local branch git branch -d <branch name>
-
Then we can update the main branch in the forked repository
# push to my fork git push origin main
-
Lastly, we push the deletion of the feature branch to forked repository
# delete feature branch from my fork git push --delete origin <branch name>
-
There will be three Git repositories involved:
- upstream - the Omega repository on GitHub.
- origin - your GitHub fork of
upstream
. This repository will typically be at a URL that looks likegithub.com/_your_user_name_/Omega
- local - your local clone of
origin
Follow these steps to get ready for making changes to Omega. These steps are only needed once and not for subsequent changes you might want to make:
-
Fork the
Omega
repository on GitHub to createorigin
. Visit Omega GitHub repository and click theFork
button. -
Make a
local
clone of your fork.git clone git@github.com:_your_user_name_/Omega.git
-
Add a remote pointing from
local
toupstream
.cd Omega git remote add upstream git@github.com:GODINME/Omega.git
Here is a detailed outline of the steps needed to make changes to Omega.
-
Make a local branch in your clone and pull any recent changes into it.
git switch -c my_branch # Pick a name appropriate to your work git pull upstream main
-
Make changes and commit to local branch.
# ... editing, testing, ... git commit ...
-
Pull any changes that may have been made in the upstream repository main branch.
git switch my_branch git pull --rebase upstream main
Note that this command may result in merge conflicts. Fix those if needed.
-
Push your branch to the corresponding branch in your fork (the
origin
repository).git switch my_branch git push origin my_branch
-
Select the branch you are working on in the drop-down menu of branches on https://github.com/_your_user_name_/Omega . Then hit the
Compare and pull request
button. -
Respond to feedback, which may involve making new commits. If you made any changes, push them to github again.
git switch my_branch git push origin my_branch
Repeat as necessary until all feedback has been handled.
Note: the preceding approach will cause the pull request to become a sequence of commits. Some people like to keep just a single commit that is amended as changes are made. If you are amending commits that had already been pushed, you will have to add
--force
to thegit push
command above. -
Once I review, pull any main branch changes that may have happened since step 3.
git switch my_branch git pull --rebase upstream main
If some changes were pulled, push again to the PR, but this time you will need to force push since the rebase above will have rewritten your commits.
git switch my_branch git push --force origin my_branch
-
Ask somebody who has permissions (or do it yourself if you have permissions) to merge your branch into the main branch of the
upstream
repository. The reviewer (which is me) may do this without being asked.Select the
Squash and merge
option on https://github.com/GODINME/Omega or use the command line instructions found on that page. Edit the commit message as appropriate for the squashed commit. -
Delete the branch from
origin
:git push origin --delete my_branch
-
Delete the branch from
local
git switch main git branch -D my_branch