LoginSignup
3
4

More than 5 years have passed since last update.

[wordpress][レンタルサーバー]子テーマをgit管理する

Last updated at Posted at 2016-07-23

※.git ファイルを置くディレクトリに関して、ご指摘を受けましたので修正しました。

レンタルサーバーと wordpress でブログを公開しています。

子テーマをカスタムする際、
ソースコードを直接触るので Git でバージョン管理しておきたい。

エックスサーバー へ Git をインストール

エックスサーバーにはデフォルトで Git がインストールされていません。
バージョン管理無しで開発する気にはなれないので Git をインストールしました。

レンタルサーバなので root権限はありません。

#!/bin/sh
# alias
echo 'alias ll='ls -la' >> .bashrc
echo 'alias g='git' >> .bashrc
cd ~
mkdir opt
# gettext install
cd ~/opt
wget http://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.7.tar.gz
tar zxvf gettext-0.19.7.tar.gz
cd gettext-0.19.7
./configure --prefix=$HOME/opt
make
make install
cd ~
echo 'export PATH=$PATH:$HOME/opt/bin' >> .bashrc
source ~/.bashrc
# curl install
cd ~/opt
wget http://curl.haxx.se/download/curl-7.46.0.tar.gz --nocheck-certificate
tar zxvf curl-7.46.0.tar.gz
cd curl-7.46.0
./configure --prefix=$home/opt
make
make install
# Git install
cd ~
wget https://github.com/git/git/archive/master.zip
unzip master.zip
cd git-master
autoconf
./configure --prefix=$HOME/opt --with-curl=$HOME/opt --with-expat=$HOME/opt
make -i all
make -i install

 

無事に子テーマを Git 管理できました

テーマは、STINGER PLUS+ を使っています。

SEO強いですし、カスタムしやすくてオススメです。
※git init するディレクトリに関して、ページ下の【追記】に注意書きを書いています。

xgit1


Git でデプロイ

ローカルやクラウドIDEで編集してGitHub かどこかにホスティングすればgit pullでデプロイできます。

【追記】

テーマのディレクトリはpublicなので、.gitファイルを置くべきではありません。
wp-config(wordpressのパスワードなどが書いてあるファイル)からgit管理することにしました。

管理したいのは、子テーマだけなので .gitignore ファイルを工夫します。
スクリーンショット 2016-07-23 20.33.16

$ git ls-files
wp-content/themes/stingerplus-child

できました。

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4