Skip to content

Instantly share code, notes, and snippets.

@itzomen
Last active June 29, 2022 17:03
Show Gist options
  • Save itzomen/74cf8d3d1bbc135e6fec88f87e27efb4 to your computer and use it in GitHub Desktop.
Save itzomen/74cf8d3d1bbc135e6fec88f87e27efb4 to your computer and use it in GitHub Desktop.
Contribute to an Open-source project with GitHub
# Code Snippet
# 1. Fork the repository to your own Github account
#
# 2. Clone the project to your machine
git clone https://github.com/<your-github-username>/<repo-name>.git
#
# 3. Add Upstream or the remote of the original project to your local repository
# check remotes
git remote -v
git remote add upstream https://github.com/divanov11/Mumble.git
#
# 4. Make sure you update the local repository
# Get updates
git fetch upstream
# switch to master branch
git checkout master
# Merge updates to local repository
git merge upstream/master
# Push to github repository
git push origin master
#
# 5. Create a branch locally with a succinct but descriptive name
git checkout -b branch-name
#
# 6. Commit changes to the branch
# Stage changes for commit i.e add all modified files to commit
git add .
git commit -m "added git commands for "fork-and-pull" Git workflow"
# check status
git status
#
# 7. Following any formatting and testing guidelines specific to this repository
#
# 8. Push changes to your fork
git push origin branch-name
#
# 9. Open a PR in our repository and follow the PR template so that we can efficiently review the changes.
#
# 10. After the pull request was merged, fetch it and update the default branch of your fork
#
#### NB
1. Never Commit on the default branch, commit on branches then make a pull request
2. After making changes, if you want to make another change make sure you branch from the default branch because if you branch from branch-name, this will contain the changes from the 1st pull request except for the new pull request you working on requires the changes from the first pull request
```
# check present branch
git branch
# switch to master branch
git checkout master
# create new branch for new changes
git checkout -b 2nd-test-branch
# make new changes and push to your fork
```
3. After the pull request was merged, fetch the upstream and update the default branch of your fork
####
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment