How to clone WordPress theme from github - wordpress

I've been developing a wordpress theme on a dev site, and all along I've been pushing it to github. It's now ready to be deployed to my live site, but I'm not sure how to do that.
What I've tried so far (that didn't work) is creating an empty /wp-content/themes/my-theme/ directory on my live site, and I cd into it. Then I use git clone git#github.com:path/to/my-theme.git but that creates another directory inside of my my-theme/ directory with all of the theme files inside of it. To clarify, that now creates:
/wp-content/themes/my-theme/my-theme/[all theme files here]
But I just want the files from the github repo to be placed directly into the original empty my-theme directory that I created.

try git clone <repo> . -- you can specify the directory as the last argument.

Related

Can build_site() not overwrite .gitignore in public/?

I'm following the suggestion on this section to put the public/ folder under version control. Hugo seems to generate an automatic .gitignore files every time I build the site. The default .gitignore ignores everything except itself. Now after I run build_site(), I need to manually overwrite the default .gitignore for the changes to show up.
Is there an option that can turn off the overwriting of .gitignore?
I experienced a similar problem when generating my site with a theme I forked from github. I use git to to track changes in the course files and then to push the generated site to GitHub where the site is hosted. I created a .gitignore file in the source files for the hugo site so it would ignore .DS_Store and .icloud files but when I ran hugo -D, the .gitignore file in the generated site repo would also be modified but appear empty.
The issue was that there was extra .gitignore files lurking in the template and theme files that I had forked. Deleting them with and regenerating the site files from source without running hugo mod clean --all fixed the issue.

Git Ignore sub directory for WordPress theme

I am trying to setup GitIgnore to work with Git Tower (www.git-tower.com) and WordPress.
I want to have the repository in the root directory with the option to include just specific themes and plugins.
I will start with including just one theme sub directory.
Tower is not showing me the single theme directory. Instead it shows all of the wp-content folder. I expect this to be ignored as I have specified this in the ignore file.
So.. root: /
Directory to include: /wp-content/themes/raison-winetrust/
I tried the following:
/*
!.gitignore
!/wp-content/
/wp-content/*
!/wp-content/themes
/wp-content/themes/*
!/wp-content/themes/raison-winetrust/
Screenshot: https://www.dropbox.com/s/9lajg1h89n2jwkr/Screenshot%202015-01-23%2013.53.48.png?dl=0
Any advice appreciated.
Thanks
If you are only tracking that theme (not any of the other wordpress gubbins) why not initialise the git repo in the theme folder?
The other option is that you just do a git add of that folder and only add that folder when there are changes.

Separating Wordpress theme from system files in a git repository

I've been making a Wordpress theme and using git to save progress. My whole Wordpress site is in the git project, and I would like to remove everything except the theme folder so I can easily transplant it on other Wordpress sites.
I know one way is to just delete everything and move the theme to the root folder and commit. But checking out after that will be more complicated, right? So is there another way?
Thanks.
If you are interested in keeping the full history of your Theme folder, you can use git filter-branch and remove everything else.
See "Extract part of a git repository?" ,to be done in a clone of your current repo:
git filter-branch --subdirectory-filter Project/SubProject-0 --prune-empty -- --all

What causes a fatal: not a git repository error?

I am working on webpage, and I need version tracking, so I'm uploading it to github.
Here is the underlying set up.
https://developers.google.com/appengine/articles/wordpress
Now that I have the base CMS ready to go, I need to get the base code uploaded before I start making changes.
lloydm#lloydm-E6320:~/Downloads/rtt/rtt-code$ pwd
/home/lloydm/Downloads/rtt/rtt-code
lloydm#lloydm-E6320:~/Downloads/rtt/rtt-code$ git status
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# wordpress/
nothing added to commit but untracked files present (use "git add" to track)
lloydm#lloydm-E6320:~/Downloads/rtt/rtt-code$ ls
app.yaml cron.yaml php.ini wordpress
lloydm#lloydm-E6320:~/Downloads/rtt/rtt-code$ git add .
fatal: Not a git repository: wordpress/wp-content/plugins/../.git/modules/appengine-wordpress-plugin
I've never used github before, so I was just following the github website stuff. I have zero idea what this error means or how to prevent it. I can't find anything that I think is related to it.
You need to set up your git repo correctly.
I think you followed this section "Installing WordPress on your development environment" from the link you provided https://developers.google.com/appengine/articles/wordpress
So what you did was download WordPress into your folder which you set up to be a .git repository. However, the WordPress project builder you downloaded itself contains a .git repository.
Check if you have a /workpress/.git file. It likely contains something like :
gitdir: ../.git/modules/wordpress
If you do, then that explains the error I think.
As for setting it up correctly, there are many tutorials available.
One way is to use Git for theme deployment, rather than having it manage your entire WordPress installation --> http://culttt.com/2013/04/08/how-to-deploy-wordpress-themes-with-git/
Another way is to add wordpress as a submodule http://www.efeqdev.com/website-development/this-is-how-we-version-control-and-deploy-our-wordpress-websites-with-git/
or Just make a ~/Downloads/rtt/rtt-code/wordpress/myWebpage directory and set up a git repo in it. http://www.whistlenet.com/git-for-wordpress/
I think you just need to go into the wordpress folder and then run the git status command. As the directory(rtt-code) is not a git directory but contains within it the git repo, that is wordpress, you are getting this error.
Inside the wordpress folder, all your git commands would work perfectly well...

Keeping WordPress in version control - separate repo for theme

I have my WordPress project under Git and have WordPress as a submodule. I want to keep my theme development in a separate submodule, but within the current setup and am having some difficulties getting the theme setup as a submodule.
Here is my file system:
/.git (master repo)
/index.php
/wp-config.php
/wordpress (WordPress repo as a submodule)
/wp-content
themes
test-theme (theme repo)
.git
index.php
(etc...)
Now when I push my master repo to github, and try and clone it on another machine, the wordpress submodule downloads fine, but my theme folder does not, and I get an error about submodule not being defined.
I've tried using this to add my theme as a sub-module:
git submodule add ./wp-content/themes/test-theme/.git ./wp-content/themes/test-theme
but I get the following error: "remote (origin) does not have a url defined in .git/config"
How do I defined my theme repo as a submodule, when it is essentially hosted "inside" the project and not at a separate repository online?
Thanks.
I'm still relatively new to using submodules but I have been trying to do something similar and found two blog posts quite helpful: one by Clint Berry and another by David Winter.
The principle of a submodule is that it should have a separate repo and then when you add that submodule to a new project the add submodule command should be pointing to the repo:
git submodule add https://github.com/youruseraccount/test-theme.git ./wp-content/themes/test-theme
git init
git update
I believe this is why you are getting the error, there is no URL associated with the origin. Look in the files .gitmodule and .git/config to confirm. If I am correct, the git init will add the necessary entries in .git/config and git update this will pull the theme from the repo and put it into the subdirectory.
See here for how to commit changes to the submodule and here for how to remove the submodule.

Resources