Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error using 'git add': "-bash: syntax error near unexpected token `('"

Tags:

bash

I can not commit and pull because of an unmerged file.

U    user_data/post_img/kesongxie/LuYWf7nM915SQ0X/003(2).JPG
fatal: 'commit' is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>' as
appropriate to mark resolution and make a commit, or use 'git commit -a'.

I have tried git add -A and then commit, but it's still not working. When I tried

git add user_data/post_img/kesongxie/LuYWf7nM915SQ0X/003(2).JPG

it says

-bash: syntax error near unexpected token `('

Besides, I have manually removed the file and even the directory post_img and then committed again, but it remains the same. What would be the problem?

like image 307
Kesong Xie Avatar asked Dec 25 '22 05:12

Kesong Xie


1 Answers

Try this:

git add "user_data/post_img/kesongxie/LuYWf7nM915SQ0X/003(2).JPG"

Otherwise, Bash will try to do something with that (2) in the file name.

If you removed the file and want to also remove it from Git, you have to call rm instead:

git rm "user_data/post_img/kesongxie/LuYWf7nM915SQ0X/003(2).JPG"

Or you can also use git add -u to update files Git already knows about (which will remove the file too).

like image 50
poke Avatar answered Jan 26 '23 00:01

poke