0

In SourceTree I try to reverse a commit but I get this error:

error: The following untracked working tree files would be overwritten by merge:
    sites/default/files/php/twig/.htaccess
    sites/default/files/php/twig/5a28f4da_block.html.twig_7fdf7759ac5e05b56cecaa39f0b0b24227af874948f93eb3bebb14c9aa894bed/.htaccess
    sites/default/files/php/twig/5a28f4da_html.html.twig_a24499b556ded443d175ee53d9f684a5e80725b925c497f5ab92d5181467f3e4/.htaccess
    sites/default/files/php/twig/5a28f4da_page-title.html.twig_91e36ad5fced0c7956bcff8cb739ec0bf4854d46bf202218c344fc3a0d43ff78/.htaccess
    sites/default/files/php/twig/5a28f4da_page-title.html.twig_ae9f32c69b10e2a28019a348c025f0bc6a933c63472f540c10609bc8808faf17/.htaccess
    sites/default/files/php/twig/5a28f4da_page.html.twig_e98316829f88ea4fc6b16b37056f0f3adefa7a60d82af8e5a1df73762808a306/.htaccess
    sites/default/files/php/twig/5a28f4da_region--header.html.twig_c1997eeb08b7d8ff4138be121a639c92134e6e24eed2a368375f02e5602cf34e/.htaccess
    sites/default/files/php/twig/5a28f4da_region.html.twig_2faa3d1db693fe574b3a07bc0abb48f55576718a4c6f82784d91424dc55f0833/.htaccess
    sites/default/files/php/twig/5a28f4da_region.html.twig_311ddf326c3de6a6e9b8316f6f2b88f501e51bf84e82b8fa0d148f094acefd22/.htaccess
    sites/default/files/php/twig/5a28f4da_status-messages.html.twig_450b13c3ebfd7aa08c49fc265d16913f68d48fd1c0e7cb78497196525a8054ed/.htaccess
    sites/default/files/php/twig/5a28f4da_status-messages.html.twig_69862b5840cc89b710bf715ac3450e6a22f228bd791564412fd34ff74af41304/.htaccess
Please move or remove them before you can merge.
Aborting
Completed with errors, see above

What do I have to do to reverse this commit?

meez
  • 3,783
  • 5
  • 37
  • 91

1 Answers1

1

You could use git clean -f to get rid of these files.

It seems you have local changes in the working directory. You could git stash your local changes in the current branch and then follow.

But from the message you provided, it seems these are some log files that get updated on their own. You should ideally put them in the .gitignore file.

To quickly remedy the issue, you could also use git rm --cached sites/default/files/php/twig/ followed by a checkout of the same.

Ravi Tiwari
  • 946
  • 8
  • 17
  • Thanks. So can I begin with doing `git rm --cached sites/default/files/php/twig/` ? What do you mean with "followed by a checkout of the same" ? – meez Apr 13 '16 at 09:39
  • git rm will remove these files from the staging area. So you need to checkout these files again. – Ravi Tiwari Apr 13 '16 at 09:42
  • Ok what means "checkout these files again" exactly ? – meez Apr 13 '16 at 09:44
  • With `git rm --cached sites/default/files/php/twig/` I get `fatal: pathspec 'sites/default/files/php/twig/' did not match any files` – meez Apr 13 '16 at 09:50
  • These files are untracked, meaning they are not in your index, meaning there is nothing to `git rm --cached`. The problem is that they *are* in some commit that you have picked up from someone somewhere, and perhaps they should not be (I'm not sure what a `.../php/twig/` file might be). – torek Apr 13 '16 at 09:56
  • Try using `git stash` in the current branch – Ravi Tiwari Apr 13 '16 at 09:59
  • `git stash` gives No local changes to save. What do I have to do? In the error I see: Please move or remove them before you can merge – meez Apr 13 '16 at 10:01
  • Completely missed the fact that these are untracked files. If these files are not required for the project, you could simply delete them. In case you do not want to delete, add these to the `.gitignore` file. – Ravi Tiwari Apr 13 '16 at 10:28