Clone your fork to your local machine
- Fork the repository you are working on.
- Go to your GitHub account, open the forked repository, click on the code button and then click the “copy to clipboard” icon if you intend to use a command-line tool.
- Open the terminal and run the following git command:1git clone “URL you copied from the clipboard.”
Add 'upstream' repo to list of remotes
- Keeping your fork up to date while this isn't a necessary step. If you plan on doing anything more than a tiny quick fix, you'll want to make sure you keep your fork up to date by tracking the original "upstream" repo that you forked earlier.
- To do this, you'll need to add a remote. An example of the command is given below:Here “meshery" is used as the example repo. Be sure to reference the actual repo you are contributing to.1git remote add upstream https://github.com/layer5io/meshery.git
Create and checkout a new branch
- Whenever you begin to work on a new feature or bugfix, it's important that you create a new branch. Not only is it a proper git workflow, but it also keeps your changes organized and separated from the master branch so that you can easily submit and manage multiple pull requests for every task completed.
- Perform the flow:For example,1 git checkout -b your-new-branch-name(feature being a branch name)1git checkout -b feature
Make the necessary changes to your file.
- To add the changes you have made to your branch, use:1git add <file>
- If you add multiple file changes to the branch, you simply use:1 git add .
Commit the changes made
- Now commit those changes using the git commit command:1git commit -s -m “This is my commit message”
Make sure to Sign-off on your Commits (Developer Certificate of Origin)
To contribute to this project, you must agree to the Developer Certificate of Origin (DCO) for each commit you make. The DCO is a simple statement that you, as a contributor, have the legal right to contribute.
To signify that you agree to the DCO for contributions, you simply add a line to each of your git commit messages:
1Signed-off-by: Jane Smith <jane.smith@example.com>
In most cases, you can add this signoff to your commit automatically with the -s or --signoff flag to git commit. You must use your real name and a reachable email address (sorry, no pseudonyms or anonymous contributions). An example of signing off on a commit:
1$ commit -s -m “my commit message w/signoff”
To ensure all your commits are signed, you may choose to add this alias to your global .gitconfig:
1[alias] amend = commit -s --amend cm = commit -s -m commit = commit -s2
Or you may configure your IDE, for example, Visual Studio Code to automatically sign-off commits for you:
Push changes to Github
- To push your changes, run the git command:1git push origin your_branch_name
Create a pull request (PR)
- Head over to your forked repository on GitHub and you'll see a Compare & pull request button. Click on that button.
Note: Please ensure that the right branch is selected for the PR.
- Once you click on the button, you'll be taken to the Pull Request page. Here, you can add a title and description to your pull request that explains your contribution. Once you're done, click on the Create pull request button.