Skip to content

Add git command quick reference for git.md #2384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/git.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,33 @@ please [open an issue] so we can document how to fix it.
[documentation]: https://docs.github.com/en/get-started/quickstart/set-up-git
[guides]: https://guides.github.com/introduction/git-handbook/

## Quick Reference

Here are the most common Git commands you'll use when contributing to Rust:

- [Set up repository](#prerequisites)
```sh
# Setup: Add upstream remote to your fork
git remote add upstream https://github.com/rust-lang/rust.git
```
- [Start new work, and Keep up to date with upstream](#keeping-things-up-to-date)
```
# Start new work
git checkout master
git pull upstream master --ff-only
git checkout -b my-feature-branch
```
- [After resolving conflicts during rebase](#rebasing-and-conflicts)
```
git add <resolved-files>
git rebase --continue
git push --force-with-lease # Update your remote branch
```
- [Prevent creating merge commits (recommended)](#no-merge-policy)
```
git config pull.ff only
```

## Prerequisites

We'll assume that you've installed Git, forked [rust-lang/rust], and cloned the
Expand Down