-
Notifications
You must be signed in to change notification settings - Fork 1
IDEA Development Collaboration Best Practices
This document attempts to standardize the collaboration procedures when contributing to IDEAconsult's repositories on GitHub. The main goal is to ensure efficiency and consistency in the work process and the overall quality of the final product.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.
- Use pull requests whenever possible. Direct commits to
master
are acceptable only for trivial changes. - Use separate branches for each enhancement or fix you're working on, unless the circumstances dictate otherwise.
- Give the branches appropriate names, e.g.
fix/238
(where 238 is the issue number) orehn/my-awesome-feature
. -
DO NOT merge new commits from
master
to your branches: either rebase your branches tomaster
or wait till the final merge intomaster
. See Avoiding automatic merges on pull below. - Once the branch is ready to be merged, rebase it again, preferably interactively. It SHOULD be able to be fast forwarded (
--ff-only
) even if a merge commit (--no-ff
) is planned.
- Fork the repo you want to contribute to into your account.
-
git clone https://github.com/youraccount/forkedrepo
(q.v. git clone) -
git remote add upstream https://github.com/ideaconsult/forkedrepo
(optional, see Rebase below, q.v. git remote) -
git checkout -b enh/coolfeature
(q.v. git checkout, git branch, in GitHub) - Make your commits.
- Rebase (optional, but highly desirable unless circumstances dictate to use merge):
git fetch upstream master
git rebase -i upstream/master
- Use the appropriate commands for each of your commits. In particular, you may want to
squash/fixup
commits that had only been intermediate stages. Remember thatrebase
rewrites the branch history! (q.v. git rebase, squash et al.) -
git push -u origin enh/coolfeature
(note that you MUST push to your forked repo, not to the original one you forked from; q.v. git push, git remote) - Create a pull request for the original repo from your newly pushed branch.
- If necessary, continue pushing commits to that branch, while rebasing if master is updated, until the pull request is accepted.
For more detailed information, see Syncing a fork.
git fetch upstream
-
git checkout master
(or whatever branch you want to sync) -
git merge upstream/master
(remember that in general you MUST keep your own commits in separate branches!) -
git push origin master
(remember that origin is the remote name of your fork; seegit remote -v
)
To avoid the undesired automatic merge and attempt automatic rebase instead, set the following Git option in one of the two ways:
- for this repo only:
git config pull.rebase true
- for all Git repos:
git config --global pull.rebase true
After setting the option, if are remote commits that you don't have locally the automatic rebase may fail. In these cases you'll need to resolve the conflicts by yourself. See git rebase for further details.
If the above steps aren't carried out, recent versions of Git produce the following warning:
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint:
hint: git config pull.rebase false # merge (the default strategy)
hint: git config pull.rebase true # rebase
hint: git config pull.ff only # fast-forward only
hint:
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.