-
Notifications
You must be signed in to change notification settings - Fork 746
docs: add coming from git guide #7704
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
Open
sirodoht
wants to merge
1
commit into
jj-vcs:main
Choose a base branch
from
sirodoht:add-coming-from-git
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
# Coming from Git | ||
|
||
> This tutorial is about guiding someone who has a working Git repository | ||
> to get started with Jujutsu quickly. It assumes the reader is at least vaguely | ||
> familiar with the basics. Get started with understanding the basic concepts at | ||
> our [tutorial](../tutorial.md). | ||
|
||
## Minimal risk | ||
|
||
Since Jujutsu is compatible with Git, you can colocate a Jujutsu repository | ||
and an existing Git repository. This makes adopting Jujutsu very easy as well as | ||
minimally risky: if something breaks or you want to go back, just delete your | ||
project's `.jj/` directory. | ||
|
||
## jj init for existing Git repositories | ||
|
||
Assuming you have [installed](../install-and-setup.md) Jujutsu, you can | ||
initialize a | ||
[colocated repository](../git-compatibility/#colocated-jujutsugit-repos) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, i'd leave out colocated |
||
in an existing Git repository on your computer like so: | ||
|
||
```sh | ||
cd ~/whatever/project | ||
jj git init | ||
``` | ||
|
||
You can even do this in a Git repository with a dirty working directory. | ||
|
||
## Write the code | ||
|
||
Write some code or decide it's time for a commit for some of your current | ||
changes in the working directory. | ||
|
||
Write the commit message: | ||
|
||
```sh | ||
jj describe | ||
``` | ||
|
||
Awesome! On most `jj` commands, the first thing Jujutsu will do is auto-commit | ||
all changes (with an empty commit message), so what you just did with | ||
`jj describe` is to write this _existing_ commit's message. This commit | ||
includes all the current changes. | ||
|
||
## Splitting instead of committing | ||
|
||
You wrote a bunch of code but some of it can't go in that single commit. What | ||
you do now is: | ||
|
||
```sh | ||
jj split | ||
``` | ||
|
||
Now, if you have a terminal without a mouse (or have mouse completely disabled | ||
in your terminal because it constantly gets in the way, like I do) this next | ||
screen might confuse you. Interestingly, it was the reason I gave up on jj the | ||
first time. Here's how this "interactive" screen works: | ||
|
||
1. Use the arrows to go up and down the file list | ||
1. Hit space to select the files that will go to the first commit | ||
1. Press `c` to confirm your selection | ||
1. Change the commit message for that first commit, and save | ||
1. Change the commit message for that second commit, and save | ||
|
||
Of course, for that second commit, you might decide to split again later. That's | ||
part of the game. | ||
|
||
## Time to push | ||
|
||
Ok, work done, how to push? | ||
|
||
We don't push branches in Jujutsu as we do in Git. Instead, we push `bookmarks`. | ||
Branches are like tree branches: they fork off `main` and grow. Bookmarks are | ||
like book _marks_: you constantly grow the book and at some points you put | ||
bookmarks. This means that in Git every new commit is automatically part of a | ||
growing branch. In Jujutsu, every new commit is part of the whole book and | ||
nothing else. If you want it to be part of a Git branch, you assign a bookmark | ||
to it: | ||
|
||
```sh | ||
jj bookmark create fix-login -r @ | ||
# this means I create a new bookmark in the latest/current commit (signified by @) | ||
|
||
jj git push -b fix-login --allow-new | ||
# this means push bookmark/branch to default origin and also create the branch | ||
``` | ||
|
||
## Two small tips | ||
|
||
You can always do: | ||
|
||
```sh | ||
jj status | ||
# or jj st | ||
``` | ||
|
||
to see an overview of the working directory. | ||
|
||
You can always do: | ||
|
||
```sh | ||
jj log | ||
``` | ||
|
||
to see the most recent relevant commits (i.e. working copy commit and ancestor | ||
plus any other mutable — unpushed — commits) along with messages and any | ||
bookmarks on those commits. | ||
|
||
## More changes | ||
|
||
You pushed your bookmark branch, opened a PR on GitHub, asked for review, and | ||
some annoying nitpickers ask for changes. Fine: | ||
|
||
```sh | ||
vim code.txt | ||
# :wq | ||
jj describe -m "fix serious issue" | ||
|
||
jj bookmark move -f fix-login -t @ | ||
# this means move the fix-login bookmark from [-f] its original place to [-t] latest commit (aka @) | ||
|
||
jj git push -b fix-login | ||
# and then just push | ||
``` | ||
|
||
## Concluding the workflow | ||
|
||
After pushing the changes, you get an approval, and merge your PR. Now what? | ||
Pull changes: | ||
|
||
```sh | ||
jj git fetch | ||
# git fetch, classic | ||
|
||
jj new main | ||
# prepare new commit following the latest commit of main branch, not fix-login | ||
|
||
# or: | ||
jj new | ||
# prepare new commit following the last one, part of fix-login branch | ||
``` | ||
|
||
...and that's the end of the standard GitHub workflow. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little jargon-forward, I'd consider trying to re-write it to something more like