Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the prompt "Do you want to add the following file to Git?" do exactly?

I have been pressing "No", but GitHub Desktop still lists it as being staged and ready to be committed. My partner, him, uses the Command Prompt and not GitHub Desktop, and has been pressing "Yes" and reports the same behaviour (the file gets committed).

So what exactly does this prompted message do ?

NOTE: We both use IntelliJ, which is the application prompting us this message.

EDIT: Adding the screenshot below for clarity. The green item is the result of me selecting 'YES' on the prompt, and the red item is the result of me selecting 'NO' on the prompt. We can see they both are presented in the GitHub Desktop application anyways. The question is thus: what does this prompt do?

The prompt

After prompt - showing results

Git status

EDIT: Current set up:

IntelliJ IDEA 2018.1 (Community Edition) Build #IC-181.4203.550, built on March 26, 2018 JRE: 1.8.0_152-release-1136-b20 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.0

GitHub Desktop 1.2.6

EDIT: Now updated IntelliJ to latest version:

IntelliJ IDEA 2018.1.6 (Community Edition) Build #IC-181.5540.7, built on July 11, 2018 JRE: 1.8.0_152-release-1136-b39 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.0

Here is a screenshot of the gitstatus (but both files still get listed in GitHub Desktop as being ready to be committed) :

Latest version IntelliJ screenshot

like image 755
payne Avatar asked Oct 17 '22 16:10

payne


1 Answers

In order to see the exact command IntelliJ IDEA executes you can go to View > Tool Windows > Version Control (Alt + 9). In that view, you select the Console tab. See image below:

enter image description here

Once there you can see what it does exactly by adding a new file (Right click in project folder > New > Java Class). Let's call it "MyFile.java".

When the confirmation prompt shows up, if:

  • No is selected, nothing happens, the console shows nothing and the file remains "non-added" to version control.

enter image description here

  • Yes is selected, the following command is shown in console:

    14:48:46.853: [valuedemo] git -c core.quotepath=false -c log.showSignature=false add --ignore-errors -- src/main/java/com/lealceldeiro/valuedemo/MyFile.java

The relevant part here is git -c core.quotepath=false -c log.showSignature=false add --ignore-errors -- src/main/java/com/lealceldeiro/valuedemo/MyFile.java, which basically adds the file "MyFile.java" with the core#quotepath and log#showSignature values to false and ignoring any error.

If you have any doubts about the state of the files you can use git status and if there is a file you do not want to commit you can use git rm. Actually if we want to remove our previously added "MyFile.java" through the IDEA UI, we can do Right click on the file > Git > Revert > Revert and it will print in VCS console git -c core.quotepath=false -c log.showSignature=false rm --cached -f -- src/main/java/com/lealceldeiro/valuedemo/MyFile.java


See more about:

  • git -c
  • [core] config
  • log.showSignature
  • add
  • --ignore-errors

Tested with IntelliJ IDEA 2018.1.5 (Ultimate Edition), Build #IU-181.5281.24, built on June 12, 2018.

like image 194
lealceldeiro Avatar answered Oct 19 '22 23:10

lealceldeiro