0

IntelliJ has this nice features with a commit-tab in their IDE, which allows you to see all the changes in all files, and also has the revert-button and a lot of other useful functions that I like.

The thing is that those files are only shown there when they are uncommited and then when I commit they disappear (as they should)

enter image description here

Now I have been working a few weeks on a project, and I have made 5 commits, and after each commit the window is cleared out, so they are no longer present in that window.

Question: If I squeeze all commits into one, with:

git rebase -i HEAD~5

Will that make all of the previous commited files to appear in this window again, so I can clean up and make a push to remote repo?

cb4
  • 6,689
  • 7
  • 45
  • 57
klabbaparn
  • 157
  • 3
  • 9
  • I don't use IntelliJ so cannot say for sure, but: if you use `git reset HEAD~5` or `git reset --soft HEAD~5` (**do not** use `--hard` here!), you'll be in a situation in which you're about to make a single Git commit that has all files unstaged (`reset --mixed` / default) or staged (`reset --soft`) as if you'd never made the last 5 commits. For safety / convenience / general reassurance, consider doing `git branch save-where-i-am-now` before the `git reset` step so that you have a branch name by which you can easily go back to where you were. – torek Jan 20 '22 at 21:41
  • In command-line Git, this would do precisely what you want (with the mixed reset you'd need to `git add` first, and with `--soft` you can `git diff --cached` to view the proposed commit). If IntelliJ notices the updates to Git's index and/or your working tree, it may pick up on all this automatically. If not, there may be some clicky GUI way to make it pick up. – torek Jan 20 '22 at 21:43
  • Ok, this seems like the thing that I want. Question. About the "git branch save-where-i-am-now" do you mean that I should create and checkout a new branch that I can have as backup? In that case, do you mean "git checkout -b save-where-i-am-now" ? – klabbaparn Jan 20 '22 at 22:15
  • No, I mean before `git reset`, create a new branch pointing to the current (HEAD) commit. The `git reset` is going to move the current branch back five steps. To "move forward" again is painful (you can consult the reflogs but they're so full of data that it's hard to find the *useful* part). Creating a `backup` branch, or whatever you want to call it—I tend to use numbered names, e.g., if I'm on `feature/tall` I make a `feature/tall.0`, then `feature/tall.1`, and so on for each backup—gives you an easy way to find the commit. Later, I delete my backup names.) – torek Jan 20 '22 at 22:35

2 Answers2

0

Commit toolwindow shows only recently added to git files or files that have been modified.

If you run rebase then you won't see these files/commits in Commit toolwindow since they already will be commited.

But you may see files in Commit toolwindow during rebase if there will be any commits.

Will that make all of the previous commited files to appear in this window again, so I can clean up and make a push to remote repo?

As an example, you can squash your commits (Go to Log tab-> hold Ctrl -> choose desired commits and right-click Squash), then you can push them as a single commit. (Click on Push action or pres Ctrl/Cmd+Shift+K)

In push dialog you will see which commits exactly will be pushed.

But it won't make these files appear in commit dialog. There is no need for these files to be in commit dialog in order to be pushed.

Ruslan Kuleshov
  • 1,934
  • 1
  • 7
  • 11
0

You cannot make them reappear in the commit tab but you can see them any time you want.

  1. Go to the Git tab. If you can't see it, go to View | Tool Windows | Git
  2. Click the Log tab and select any branch
  3. Click a commit in the middle pane and you will see the changed files in the right pane. If they're not sorted right, click this icon enter image description here
  4. Double-click a file to see diffs with current tree or right-click for a context menu

enter image description here

cb4
  • 6,689
  • 7
  • 45
  • 57