Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving committed git files to another directory

Tags:

git

commit

reset

I've been doing development work in a 'dev-test' directory and committed files along the way. I now need to commit those same files to a differently named directory and remove the committed files in the 'dev-test' directory. I'm not sure how to retain my working files.

My 'dev-test' repo is local, but I have been doing pulls that are tracking as 'master', but I have not merged my code.

Can I use git reset before my first commit of these files as other developers have been merging into 'master':

git reset --soft #commitID
like image 852
hybrid9 Avatar asked Nov 27 '22 11:11

hybrid9


1 Answers

Your question is still a bit unclear, but you probably want one of these:

  1. Just move the files if they aren't modifications to some other files

    $ git mv dev-test/files other-dir
    $ git commit -a
    
  2. If your test files are modifications to other files, you would want to get a diff of your work from when you started it until now and apply the patch to the other directory.

In case what you wanted was the second, you should have in fact done a different thing from the start. If you want to test something and then later apply it to master, you should create a branch, work on it and if you are satisfied, merge master into your branch. If everything was fine, then you can merge everything back to master and have everyone know about it.

like image 103
Shahbaz Avatar answered Apr 29 '23 03:04

Shahbaz