Skip to content

Commit

Permalink
[Docs]: Add some more documentation on how to work with github.
Browse files Browse the repository at this point in the history
The document roughly describes some workflows, which help new users
to start with github.
  • Loading branch information
PhilipMetzger committed Dec 21, 2022
1 parent 722f8ff commit ad93cc0
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions docs/github.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Using Jujutsu with GitHub Projects

This guide assumes a basic understanding of either Git or Mercurial.

## Setup an SSH key
As of December 2022 it's recommended to set up a ssh key to work with Github
projects. See [Github's Tutorial][gh]. This restriction may be lifted in the
future, see [issue #469][http-auth] for more information and progress on authenticated http.


## Basic workflows
You can either create a branch and then commit revisions on top of it (similiar
to how Git is typically used) or just start making changes in the repository
(which is how Mercurial is used).
This allows you to continue using your favorite way of using the VCS.

It's also possible to just commit multiple changes and set the expected branch
retroactively.

**Notable Differences to other VCS**
Branches do not move forward when creating commits on top. This means you should
set the current branch to work on before starting your work.

### Git workflow

```shell script
$ jj branch create $your-feature
$ # Do your work
$ jj commit -m "feat(xy): some thing"
$ jj git push # Note: Jujutsu defaults to pushing all branches
```

### Mercurial Workflow

```shell script
$ nvim docs/toolchain.md
$ jj commit -m "Docs: Update toolchain description"
$ # Do some more work
$ jj branch create $your-feature
$ # move all commits to your feature-branch.
$ jj branch set $your-feature -r 'remote_branches()..@'
```

This allows you to retroactively move the new revisions, to your feature branch.

## Updating the repository.
As of December 2022, Jujutsu has no equivalent to a `git pull` command.
Until such a command is added, you need to use `jj git fetch` followed by a
`jj git rebase -d $main_branch` to update your changes.

## Working in a Git co-located repository
After doing `jj init --git-repo=.`, git will be in a detached HEAD state,
which is unusual, as git mainly works with branches.
In a co-located repository, `jj` isn't the source of truth. But since Jujutsu
allows a incremental migration, since `jj commit` updates the HEAD of the git
repository.


Although `jj git import` and `jj git export` exist for co-located repositories,
they should only be used in case of an unrecoverable error.

```shell script
$
$
$
```

## Working in a Jujutsu repository
In a Jujutsu repository, the workflow is simplified. If there's no need for
explicitly named branches, you just can generate one for a change. As Jujutsu
is able to create a branch for a revision.

```shell script
$ ij .
$ # Do your work
$ jj commit
$ # Jujutsu automatically creates a branch
$ jj git push -c $revision
```


## Useful Revsets


## Merge conflicts

For a detailed overview, how Jujutsu handles conflicts, revisit the [tutorial][tutorial.md#Conflicts].

[gh]: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
[http-auth]: https://github.com/martinvonz/jj/issues/469

0 comments on commit ad93cc0

Please sign in to comment.