mirror of
https://github.com/k88hudson/git-flight-rules.git
synced 2025-03-10 12:48:43 -03:00
* added contribute other people repositories section * fix: Edits to #274 * Update README.md Co-Authored-By: Diego Sanchez <diegogsann@gmail.com> * Update README.md Co-Authored-By: Diego Sanchez <diegogsann@gmail.com> * Update README.md Co-Authored-By: Diego Sanchez <diegogsann@gmail.com>
This commit is contained in:
parent
ad141eeeb6
commit
79c67f674e
79
README.md
79
README.md
@ -28,6 +28,9 @@ All commands should work for at least git version 2.13.0. See the [git website](
|
||||
- [I want to start a local repository](#i-want-to-start-a-local-repository)
|
||||
- [I want to clone a remote repository](#i-want-to-clone-a-remote-repository)
|
||||
- [I set the wrong remote repository](#i-set-the-wrong-remote-repository)
|
||||
- [I want to add code to someone else's repository](#i-want-to-add-code-to-someone-elses-repository)
|
||||
- [Suggesting code via pull requests](#suggesting-code-via-pull-requests)
|
||||
- [I need to update my fork with latest updates from original repository](#i-need-to-update-my-fork-with-latest-updates-from-original-repository)
|
||||
- [Editing Commits](#editing-commits)
|
||||
- [What did I just commit?](#what-did-i-just-commit)
|
||||
- [I wrote the wrong thing in a commit message](#i-wrote-the-wrong-thing-in-a-commit-message)
|
||||
@ -40,6 +43,9 @@ All commands should work for at least git version 2.13.0. See the [git website](
|
||||
- [I accidentally committed and pushed a merge](#i-accidentally-committed-and-pushed-a-merge)
|
||||
- [I accidentally committed and pushed files containing sensitive data](#i-accidentally-committed-and-pushed-files-containing-sensitive-data)
|
||||
- [I want to remove a large file from ever existing in repo history](#i-want-to-remove-a-large-file-from-ever-existing-in-repo-history)
|
||||
- [Recommended Technique: Use third-party bfg](#recommended-technique-use-third-party-bfg)
|
||||
- [Built-in Technique: Use git-filter-branch](#built-in-technique-use-git-filter-branch)
|
||||
- [Final Step: Pushing your changed repo history](#final-step-pushing-your-changed-repo-history)
|
||||
- [I need to change the content of a commit which is not my last](#i-need-to-change-the-content-of-a-commit-which-is-not-my-last)
|
||||
- [Staging](#staging)
|
||||
- [I need to add staged changes to the previous commit](#i-need-to-add-staged-changes-to-the-previous-commit)
|
||||
@ -175,6 +181,79 @@ $ git remote set-url origin [url of the actual repo]
|
||||
|
||||
For more, see [this StackOverflow topic](https://stackoverflow.com/questions/2432764/how-to-change-the-uri-url-for-a-remote-git-repository#2432799).
|
||||
|
||||
|
||||
### I want to add code to someone else's repository
|
||||
|
||||
Git doesn't allow you to add code to someone else's repository without access rights. Neither does GitHub, which is not the same as Git, but rather a hosted service for Git repositories. However, you can suggest code using patches, or, on GitHub, forks and pull requests.
|
||||
|
||||
First, a bit about forking. A fork is a copy of repository. It is not a git operation, but is a common action on GitHub, Bitbucket, GitLab — or anywhere people host Git repositories. You can fork a repository through the hosted UI.
|
||||
|
||||
#### Suggesting code via pull requests
|
||||
|
||||
After you've forked a repository, you normally need to clone the repository to your machine. You can do some small edits on GitHub, for instance, without cloning, but this isn't a github-flight-rules list, so let's go with how to do this locally.
|
||||
|
||||
```sh
|
||||
# if you are using ssh
|
||||
$ git clone git@github.com:k88hudson/git-flight-rules.git
|
||||
|
||||
# if you are using https
|
||||
$ git clone https://github.com/k88hudson/git-flight-rules.git
|
||||
```
|
||||
|
||||
If you `cd` into the resulting directory, and type `git remote`, you'll see a list of the remotes. Normally there will be one remote - `origin` - which will point to `k88hudson/git-flight-rules`. In this case, we also want a remote that will point to your fork.
|
||||
|
||||
First, to follow a Git convention, we normally use the remote name `origin` for your own repository, and `upstream` for whatever you've forked. So, rename the `origin` remote to `upstream`
|
||||
|
||||
```sh
|
||||
$ git remote rename origin upstream
|
||||
```
|
||||
|
||||
You can also do this using `git remote set-url`, but it takes longer and is more steps.
|
||||
|
||||
Then, set up a new remote that points to your project.
|
||||
|
||||
```sh
|
||||
$ git remote add origin git@github.com:YourName/git-flight-rules.git
|
||||
```
|
||||
|
||||
Note that now you have two remotes.
|
||||
|
||||
- `origin` references your own repository.
|
||||
- `upstream` references the original one.
|
||||
|
||||
From origin, you can read and write. From upstream, you can only read.
|
||||
|
||||
When you've finished making whatever changes you like, push your changes (normally in a branch) to the remote named `origin`. If you're on a branch, you could use `--set-upstream` to avoid specifying the remote tracking branch on every future push using this branch. For instance:
|
||||
|
||||
```sh
|
||||
$ (feature/my-feature) git push --set-upstream origin feature/my-feature
|
||||
```
|
||||
|
||||
There is no way to suggest a pull request using the CLI using Git (although there are tools, like [hub](http://github.com/github/hub), which will do this for you). So, if you're ready to make a pull request, go to your GitHub (or other Git host) and create a new pull request. Note that your host automatically links the original and forked repositories.
|
||||
|
||||
After all of this, do not forget to respond to any code review feedback.
|
||||
|
||||
#### I need to update my fork with latest updates from original repository
|
||||
|
||||
After a while, the `upstream` repository may have been updated, and these updates need to be pulled into your `origin` repo. Remember that like you, other people are contributing too. Suppose that you are in your own feature branch and you need to update it with the original repository updates.
|
||||
|
||||
You probably have set up a remote that points to the original project. If not, do this now. Generally we use `upstream` as a remote name:
|
||||
|
||||
```sh
|
||||
$ (master) git remote add upstream <link-to-original-repository>
|
||||
# $ (master) git remote add upstream git@github.com:k88hudson/git-flight-rules.git
|
||||
```
|
||||
|
||||
Now you can fetch from upstream and get the lastet updates.
|
||||
|
||||
```sh
|
||||
$ (master) git fetch upstream
|
||||
$ (master) git merge upstream/master
|
||||
|
||||
# or using a single command
|
||||
$ (master) git pull upstream master
|
||||
```
|
||||
|
||||
## Editing Commits
|
||||
|
||||
<a name="diff-last"></a>
|
||||
|
Loading…
x
Reference in New Issue
Block a user