@@ -7,7 +7,7 @@ Getting rid of changes is very easy in `jj`: we can do it with `jj abandon`.
77
88If you remember, we're in the middle of some stuff:
99
10- {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:107:112 }}
10+ {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:114:118 }}
1111
1212If you are coming to this section fresh, just type ` jj new ` a few times to
1313give yourself some good changes. Done? Great. Let's throw them away.
@@ -17,25 +17,25 @@ give yourself some good changes. Done? Great. Let's throw them away.
1717Let's say we don't like that "hello and goodbye world" stuff. We're not going
1818to pursue that further. Getting rid of it is as easy as:
1919
20- {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:114:118 }}
20+ {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:128:132 }}
2121
2222By default, ` jj restore ` takes changes from your parent change, and puts them
2323into ` @ ` . But there's ` --from ` and even ` --into ` flags you can pass as well.
2424Let's grab the diff from our first commit, and apply it to ` @ ` :
2525
26- {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:121:125 }}
26+ {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:128:132 }}
2727
2828As you can see we aren't empty any more. Well, what does our code look like?
2929Let's use ` jj diff ` to see:
3030
31- {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:128:132 }}
31+ {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:135:139 }}
3232
3333This format is different than ` git ` 's: we have red and green to indicate
3434what's changed, for example.
3535
3636If you want to get a ` git ` style diff instead, that is easy as well:
3737
38- {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:135:144 }}
38+ {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:142:151 }}
3939
4040We only had one file that was changed, so we didn't * need* to pass the path to
4141` jj restore ` , but ` jj restore ` is mostly used with individual paths. If we
@@ -50,7 +50,7 @@ But what if we want to delete a change entirely?
5050At any time, you can get rid of a change with ` jj abandon ` . It's tons of fun!
5151Let's try it:
5252
53- {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:147:151 }}
53+ {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:154:158 }}
5454
5555This throws away our current change. We abandoned ` opqvmvrn ` , and since that
5656was the same as ` @ ` , ` jj ` makes a new change for us, in this case, called
@@ -59,11 +59,11 @@ was the same as `@`, `jj` makes a new change for us, in this case, called
5959But what if we abandon something that's not ` @ ` ? Like, let's say, ` t ` , the
6060change that we're currently on top of. What's the worst that could happen?
6161
62- {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:154:160 }}
62+ {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:161:167 }}
6363
6464So what happened here?
6565
66- {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:163:169 }}
66+ {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:170:175 }}
6767
6868As you can see, because we got rid of the commit we were standing on, instead of throwing
6969us away too, ` jj ` just re-parented us onto the abandoned commit's parent. We're still on
@@ -78,11 +78,11 @@ I have good news.
7878
7979There's a really useful subcommand that goes by ` jj undo ` :
8080
81- {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:171:175 }}
81+ {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:178:182 }}
8282
8383That's it! We're good again:
8484
85- {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:178: 185}}
85+ {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:185:192 }}
8686
8787Everything is back to where we put it. We can always ` jj undo ` to undo
8888* any* of our last operations, and ` jj ` will make things right again.
@@ -95,7 +95,7 @@ though. What do you think would happen if we `jj undo`'d again right now?
9595
9696Make your guess, and then give it a try:
9797
98- {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:188: 195}}
98+ {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:195:201 }}
9999
100100That's right: the last thing you did was an ` undo ` , so an ` undo ` just
101101` undo ` es that ` undo ` . Hilarious, but kind of frustrating. There's a
@@ -105,7 +105,7 @@ a bit trickier than it sounds.
105105Regardless, we can fix this: there's no problem with ` jj undo ` that you
106106can't solve by throwing more ` jj undo ` s at it:
107107
108- {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:197:203 }}
108+ {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:204:210 }}
109109
110110Whew. That's enough of that.
111111
@@ -114,24 +114,24 @@ Whew. That's enough of that.
114114Having an empty change with no description is fine to have if it's
115115` @ ` , or if it has children. Here's a fun party trick:
116116
117- {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:206:210 }}
117+ {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:213:217 }}
118118
119119That's right: ` jj new ` can take ` --before ` or ` --after ` flags to
120120squish a change in between others. (Yes, we're trying to make squish happen.)
121121And ` --no-edit ` means that we don't want to move our working copy
122122to the new change: ` @ ` stays right where it is:
123123
124- {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:213:222 }}
124+ {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:220:229 }}
125125
126126So that change is fine. But what if we move away from these changes?
127127Let's make a new change on top of ` trunk ` :
128128
129- {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:225:228 }}
129+ {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:232:235 }}
130130
131131We had two empty commits on top of ` goodbye-world ` before, but
132132what about now?
133133
134- {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:230:239 }}
134+ {{#trycmdinclude tests/tests/cmd/getting-started.trycmd:238:247 }}
135135
136136Our empty change ` nvnlxpxw ` was discarded, automatically. You don't have to
137137worry about ` jj new ` littering up your repository, empty changes will end up
0 commit comments