How change the folder on GIT?

I finished working on a static site using Bootstrap 4, but now to convert it to a WordPress theme I have to move it to htdocs (a different folder) a local folder for the local WordPress server.

The issue is that I have been pushing my code to GitHub using git bash from the start.

So what to do to keep tracking, committing & pushing my code to GitHub?

Any tutorials or commands with explanation are welcome?

P.S: I need to move a folder that contains many files.

In what time does he speak about moving the folder location?

:yum: what would you learn if i told you that? I only gives hint to people here how they can solute there own problem. Did you also check the github help section they do have a few threats that are somewhat like yours.

@FakhriAz an easy way to do that is to create a branch and call it something like wordpress-theme.

$ git branch wordpress-theme
$ git checkout wordpress-theme

To go back to the original version type:
$ git checkout master
That way you will have two versions of you project in Github.

@brandon_wallace You helped me do better search with your reply and I am nearly done with this,
The solution is here.

  • This is the command git worktree add [-b <new-branch>] <path>

This creates a new working tree in a new folder.

However, I still encounter an issue, the linked working tree does not sync automatically even though I did some reading and it is supposed to sync automatically.

My question is:

  • How to make the linked working tree sync automatically?

If you have the answer let me know, meantime I will keep searching and testing.

It’s a linked clone, you still need to commit, push and pull, it won’t just keep the two automatically in sync without doing that. It’s designed to be a very temporary copy that you destroy after doing a small amount of work on it. What you’re using it for is abusing the purpose of workspaces a little bit: it will definitely work, but it’s still up to you stop it diverging from the original.

@FakhriAz wouldn’t creating a new branch solve your original problem of being able to create your Wordpress theme using the code you have already created? You can push both the branches to Github.

Use these commands

git branch wordpress-theme
git checkout wordpress-theme

Push the new branch to Github
git push -u origin wordpress-theme

View local and remote branches.
git branch -a

What he wants is two branches existing in different places on his computer, and for them to stay in sync. Just having a branch like you describe is a much better idea though, but to stop it being a manual process it means that there needs to be a step that occurs whenever code is pushed to GH.

@FakhriAz if you want this automatic, then normally you would use git hooks on a branch, so when something gets pushed to the branch it automatically deploys the code to your server. This can be direct to the remote server via FTP, or you write a script that copies the code to your local server. You work on your development branch, then you merge changes to your WordPress branch when you’re ready, which deploys to the server.

This removes the issues with trying to keep a clone in sync with the original; you’re literally just copying the files to another location whenever you commit or push or whatever.