Miscellaneous algorithm implementations
Get your own fork/copy of algorithms by using the Fork button on github for the repository
Clone (download) it to local machine using the command shown below. Replace with your GitHub username instead of YOUR-USERNAME.
$ git clone https://github.com/YOUR-USERNAME/algorithms.git
This will create a local copy of the repository in your machine.
After you have cloned the algorithms
repository in Github, move to that folder first using change directory command
# This will change directory to a folder algorithms
$ cd algorithms
Rest of the commands are in this algorithms
directory
You'll see the current configured remote repository for your fork with this command [your local copy has a reference to your forked remote repository in Github ] -
$ git remote -v
origin https://github.com/YOUR-USERNAME/algorithms.git (fetch)
origin https://github.com/YOUR-USERNAME/algorithms.git (push)
Add a reference to the original algorithms repository using the following command
$ git remote add upstream https://github.com/vidyabhandary/algorithms.git
This adds a new remote named upstream.
Use the following command to check all the remotes
$ git remote -v
origin https://github.com/Your_Username/algorithms.git (fetch)
origin https://github.com/Your_Username/algorithms.git (push)
upstream https://github.com/vidyabhandary/algorithms.git (fetch)
upstream https://github.com/vidyabhandary/algorithms.git (push)
Always keep your local copy of repository updated with the original repository. Before making any changes and/or in an appropriate interval, run the following commands carefully to update your local repository.
# Fetch all remote repositories and delete any deleted remote branches
$ git fetch --all --prune
# Switch to `master` branch
$ git checkout master
# Reset local `master` branch to match `upstream` repository's `master` branch
$ git reset --hard upstream/master
# Push changes to your forked `algorithms` repo
$ git push origin master
When you want to make a contribution, create a seperate branch using the following command and keep your master
branch clean (i.e. synced with remote branch).
# It will create a new branch with name Branch_Name and switch to branch Folder_Name
$ git checkout -b Folder_Name
Create a seperate branch for contibution and try to use same name of branch as of folder.
To switch to desired branch
# To switch from one folder to other
$ git checkout Folder_Name
To add the changes to the branch. Use
# To add all files to branch Folder_Name
$ git add .
Type in a message relevant for the code reveiwer using
# This message get associated with all files you have changed
$ git commit -m 'relevant message'
Now, push your work to your remote repository using
# To push your work to your remote repository
$ git push -u origin Folder_Name
Finally, go to your repository in browser and click on compare and pull requests
.
Add a title and description to your pull request that explains your effort.