-
Notifications
You must be signed in to change notification settings - Fork 349
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
Switching between branches accumulates empty commits #1854
Comments
I hate to be that guy, but this is completely expected behavior and you are just not using jj correctly, because you are trying to use a git branching model which doesn't work as jj specifically has a different philosophy. There are no branches in jj like there are in git, you do not "checkout" a branch, What happens in your case is:
If you call A reminder of literally the main design choice/benefit of jj - there is no index, there is always this @ commit that has your changes amended to it every single time you run any jj command (aka snapshotting). You can just do the following to get the feel of it slightly, notice how there are absolutely no branches: git init && jj init --git-repo=.
touch a
jj commit -m '+a' # commit is just an alias for jj describe -m".." && jj new
touch b
jj commit -m '+b'
jj co @- # "check out" the +a commit
touch c
jj commit -m '+c'
jj log -r 'all()' # now look at the log
touch some-dirty-work
jj co <id of +b> # whoops, look, we didn't "commit" dirty work
jj log -r 'all()' # now look at the log again - it will have a child of +c with no message, which has the state of dirty work :) Also edit:
Well there obviously are branches, but they behave identically to tags, basically, and are only present for pushing to remotes and git compat |
Maybe better to not discard empty wc commit if it has a branch?
At this point,
|
I appreciate your being that guy; I'm exactly interested in understanding the philosophy to use it correctly. Here's an nearly identical sequence as the one I showed above:
The main difference being that this sequence doesn't include a That makes sense to me: While jj does make commits with BTW, perhaps just for this example where there a no descriptions, I like |
I agree.
However, branches are updated when you rewrite a commit. For example, if you change the description of some commit, then all descendants will automatically be rewritten, and branches pointing to any of them will be updated to point to the rewritten commit. |
… branch It would be confusing if a branch moved backwards by checking out unrelated commit. jj-vcs#1854
… branch It would be confusing if a branch moved backwards by checking out unrelated commit. #1854
Oh, I might've not fully understood what exactly you were describing. So you've set Basically what you're saying in Well the fix for that is already in jjs main :)
Hm, right, so git tags (which we only show and don't even have a way of creating yet) are pointers to a commit_id, and branches are more like pointers to a change_id I guess, the main difference from git I needed to highlight is that there's no "checked out" branch that moves when you make commits. |
I skimmed this thread and didn't find any action items for us. Please let me know if I missed anything. |
jj
avoids creating empty commits, but does so in the following transcript. In it, a branch is created and commits are added to it and to main. The 'main' branch label reset to the main branch usingjj branch set
to after the branch is created, enablingjj co 'heads(main:)'
to work as expected.The issue appears to surface if you
jj co
to a new branch after creating it.This behavior does not occur if you don't
jj co
to the new branch after creating it.Repro:
The text was updated successfully, but these errors were encountered: