Reputation: 2636
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.
Upvotes: 5
Views: 15909
Reputation: 47533
You probably want one of these:
Just move the files if they aren't modifications to some other files
$ git mv dev-test/files other-dir
$ git commit -a
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.
Upvotes: 30
Reputation: 279
To move a file from one directory to another you can use git mv command. For example you have 2 directories a.draft, b.pages on your git repository (gitrepo is the name in my case) . You want to move a file abc.md from draft to pages make sure you're in yor gitrepo use cd to go to your gitrepo ( you can check status by $git status as well) and write :
[zuha@localhost gitrepo] $ git mv draft/abc.md pages
It will show something like
[zuha@localhost gitrepo] $ renamed: draft/abc.md -> pages/single-batch-ex.md~
Now commit your file
[zuha@localhost gitrepo] $ git commit -m "first file"
Enter your username and password, and push it .
[zuha@localhost gitrepo] $ git push origin (your-branch)
Upvotes: 1