22

How to add files to git stage in JetBrains Rider? Is this feature implemented? If it's not implemented then in which window can I look through the staged files which I've staged using some external tool?

[UPD]: The use case is to hold separately files I want to commit and files I don't want to commit at the particular moment. Stash is not the solution because I need all changes to be present. VS has this functionality and it's very convenient. You can stage and unstage any files with a single right mouse button click.

Tsagana Nokhaeva
  • 630
  • 1
  • 6
  • 25

2 Answers2

16

To separate files that you want to commit/push later, you can use changelists.

  1. Select View | Tool Windows | Version Control (or press Alt+9) to open the Version Control tool window.
  2. In the Local Changes tab of the tool window, select one or multiple items.
  3. Right-click and select Move to Another Changelist..., or press Alt+Shift+M, to move selected items to an existing or a new changelist. Select Set active if you want all new modifications to be auto-added to the new/target checklist.

The above is applicable to Rider and all other IntelliJ Platform-based IDEs (IntelliJ IDEA, WebStorm, PyCharm, PhpStorm etc.), as well as to all version control systems that they support (Git, Mercurial, Subversion, Perforce out of the box; other VCS via plugins).

Move to Another Changelist command in JetBrains Rider

Source: Official Rider docs

Jura Gorohovsky
  • 9,886
  • 40
  • 46
  • 2
    Is there a way to unstage them back? – Tsagana Nokhaeva Nov 19 '18 at 10:36
  • @JerrySmith You mean undo an accidental stage? *Revert* should work (*VCS | Git | Revert*, `Ctrl+Alt+Z`). – Jura Gorohovsky Nov 19 '18 at 11:11
  • 1
    BTW if there's a Git command that you're looking for but it's not available or isn't immediately discoverable in Rider's version control UI, there's always an option to use the *Terminal* tool window (*View | Tool Windows | Terminal*, usually `Alt+F12`) to execute any Git command. – Jura Gorohovsky Nov 19 '18 at 11:13
  • 2
    no, I mean preserve changes but to move selected files from index to the unstaged area – Tsagana Nokhaeva Nov 19 '18 at 16:38
  • @JerrySmith I don't think there's a UI command for this. Can you elaborate why you want to do this? – Jura Gorohovsky Nov 19 '18 at 20:06
  • The use case is to hold separately files I want to commit and files I don't want to commit at the particular moment. Stash is not the solution because I need all changes to be present. VS has this functionality and it's very convenient. You can stage and unstage any files with a single right mouse button click. – Tsagana Nokhaeva Nov 20 '18 at 07:31
  • @JerrySmith Ah, you need [changelists](https://www.jetbrains.com/help/rider/Managing_Changelists.html) then. Right-click a file in *Local Changes*, and select *Move to Another Changelist...* (`Alt+Shift+M`). – Jura Gorohovsky Nov 20 '18 at 08:32
  • 1
    @JerrySmith You might want to add the use case to the question, and I will then update my answer. This will hopefully make the Q/A more searchable and useful for other visitors. – Jura Gorohovsky Nov 20 '18 at 08:34
  • 1
    Wow, changelists work like magic! And actually they are better because you can have as many of them as you want. Please, update your answer and I'll mark you as accepted. – Tsagana Nokhaeva Nov 20 '18 at 11:39
  • @JerrySmith Perfect! Updated the answer. – Jura Gorohovsky Nov 20 '18 at 13:55
  • 1
    I've found recently that changelists allow you to move parts of the same file from one changelist to another. Right click on the file in the changelist --> show diff --> right click to the particular change --> move to another changelist. That makes changelist the complete replacement for git stage. – Tsagana Nokhaeva Jan 30 '19 at 10:17
8

The staging area is an alternative to changelists that @Jura Gorohovsky has mentioned. For those more comfortable with the concept of staging changes on a file-by-file basis like the Visual Studio experience you described, you basically need to do two things:

1. Enable Staging Area

  1. Open the Rider IDE settings (File > Settings... or Ctrl+Alt+S)
  2. Search for "stage",
  3. Click to [x] Enable staging area

enter image description here

2. Open the Commit Window and Stage Your Files

  1. Open the Commit window (View > Tool Windows > Commit)
  2. On your desired file Right-click > Stage (or individually Unstage)
  3. As you enter a commit message and click Commit, it will commit only the files you've staged

There's a ton of other more complex maneuvers (see Reference) but that's the basics.

enter image description here

Reference: Official Docs for staging area to commit changes

Pang
  • 9,564
  • 146
  • 81
  • 122
Eric D. Johnson
  • 10,219
  • 9
  • 39
  • 46