Git question

I moved a bunch of smarty template files to a sub directory. When I issue git status it shows the new directories but also shows the old files deleted.

Is it safe to issue "git rm directory/oldfile.tpl" then "git add directory/directory2/newfile.tpl" ?
Robert SaylorSenior DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jeff DarlingDeveloper AnalystCommented:
Do you see the new files that were created in the sub folder?

How did you perform the move?  Was it using git or command line move or windows explorer?

Is the history of the files prior to the move important to you?
Robert SaylorSenior DeveloperAuthor Commented:
Yes, the new files are in the new folder. I manually moved them from the old location to the new location using the file system.

The files are stored on a linux server but I moved them via Mac finder on a mounted volume (remote web disk)

I will make a backup first before I commit just want clarification this is ok or is there a proper way to move files in a repository.
Robert SaylorSenior DeveloperAuthor Commented:
oh, the history is not important on these files as there is minor or no change from the original. Was adding organization as I have too many template files already in my project.
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Jeff DarlingDeveloper AnalystCommented:
There is a move command in git that is the way to do it.  

mkdir -p x/p/q      # make sure the parent directories exist first
git mv x/* x/p/q    # move folder, with history preserved
git commit -m "changed the foldername x into x/p/q"

Open in new window

If you don't care about the history, you could add them.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Robert SaylorSenior DeveloperAuthor Commented:
if I wanted to move a single file would it be:

git mv directory/filename.ext directory/directory2/filename.ext

Robert SaylorSenior DeveloperAuthor Commented:
just a followup. I committed my changes this morning. I safely added the new directories and removed the old files that are no longer in the old directory. Git treated it as a rename. All is good.

I have some more files to organize this week so will give the git mv a try then.

My template directory was getting close to 50+ files so was making it hard to keep things straight.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.