1

I am using IDE PhpStorm with github support.

I have made changes to files in a certain directory. I want to commit and push those changes.

On that folder i press: Rightclick > Git > Commit directory

Up untill now that has always worked, but now suddenly it also commits file from other directories.

Next to that, all my files have turned red, but when i press compare with branch the files show no changes.

Any idea what is causing this behaviour and how i can commit only that directory?

bahrep
  • 29,961
  • 12
  • 103
  • 150
user4493177
  • 750
  • 11
  • 32

2 Answers2

3

In phpStorm, any files that appear in red are not a part of your git repository. Only files that are green (modified files) or blue (new files). You should review your files in the 1: Project pane of phpStorm to make sure you have the right files in your repository to begin with.

Next, visit your 9: Version Control pane of phpStorm to review the status of new or modified files. Enable the directory view here by clicking the [Folder] icon (see screenshot). Then click the Expand All icon (first option, top of right column in the 9: Version Control pane) to reveal all of the files that git thinks you need to commit. From here, right-click the folder (or even individual files!) you want to commit and let it rip!

Important: Only folders you have added to git will appear in the 9: Version Control pane, so if you haven't added individual folders to git yet, you can't commit them.

enter image description here

Because git is so incredibly efficient at storing changes to your files, it is best to just commit all the files anyways, but you can pick which folders or individual files to commit from here at will.

0

If you want to remove a directory/file from git repository:

  • In Phpstorm select Tools -> Run Command
  • Enter git rm directoryYouWantToRemove

See How can I delete a file from git repo?

If you want to let git ignore files or directories

Create a file called "gitignore"

List all files or directories in this file by simply adding the name of the file or directory on each line.

For example in that file just fill in the name of the directory in gitignore:

directoryYouWantToIgnore

More information: http://git-scm.com/docs/gitignore

Community
  • 1
  • 1
Luke
  • 1,768
  • 2
  • 20
  • 30
  • Thanks for your comment. However my problem is that earlier it seemed to be possible only to commit changes from a certain directory regardles of the ignore rules, since phpStorm has a function called commit directory. Now this function also commits files outside that directory. – user4493177 Jul 23 '15 at 14:23
  • i believe that you commited those files to the repository. If i am right than you need to delete those files from your repository if you don't want them. – Luke Jul 23 '15 at 14:25
  • no didnt commit them yet, but i i press commit directory it shows all those files. Even now i have placed the folder in a .gitignore file, and they still show up on the commit list – user4493177 Jul 23 '15 at 14:31
  • what exactly does this do? Does it change my files? – user4493177 Jul 23 '15 at 14:40
  • *Git->Revert* _may_ change your files. After choosing to revert, it will say: "new: 1 of xxxx, 0 of yyyy modified." What this means (in this example) is that reverting will cause "1 of xxxx new files" to be removed from Git, and "0 of yyyy modified files" will go back to an older version. In this example, 1 new file will be removed from git, but none of the files (0 of yyyy) have been modified so the file will stay the same. – unrivaledcreations Jul 23 '15 at 16:49