MacのEmacsでmagitを使っているが、久しぶりにM-x magit-statusを実行すると、
magit-auto-revert-mode: Symbol’s value as variable is void: executable-find
となる。どうやらmagitが古いようなので更新した。
M-x package-list-packages として古いmagitを削除し、最新のmagitを再度インストールした。
カテゴリー: Git
Git使いになろう:複数のPCで使う準備
今まで、VirtualBoxの仮想マシン上にローカルのリポジトリを置いて実施していましたが、仮想マシンが起動できなくなってしまいました。そこで、仮想マシンを作り直すのと同時に、Gitも複数PCで使えるようにしました。
まずは、仮想PC(Debian GNU/Linux)にローカルリポジトリ(sandbox)を作りなおし、できるだけ以前と同じ状態にしました。
1 2 3 4 5 6 7 8 9 10 | $ ls -a . .. .git sample.txt $ git branch develop * master $ git log --oneline 88d4d60 (HEAD -> master) add URL description 814a977 add Start date of site 13cc07f add URL efdad3c (develop) first commit |
次に、RaspberryPiにリモートリポジトリを作成します。
場所は、/var/repos/git/sandbox.git
としてgitグループのユーザーがアクセス可能に設定します。
1 2 3 4 5 6 7 | # mkdir -p /var/repos/git/sandbox.git # cd /var/repos/git/sandbox.git # git init --bare --share # useradd git # cd /var/repos # git:git -R git # gpasswd -a tomohiro git |
そうしておいて、VirtualBoxのsandboxからリモートリポジトリにPush。
developブランチもあるのでこちらもPush。
1 2 3 4 | $ git remote add origin ssh : //192 .168.1.96: /var/repos/git/sandbox .git $ git push origin master $ git checkout develop $ git push -u origin develop |
別のPC(母艦)でリモートリポジトリをローカルにコピーします。
1 2 3 4 5 6 7 8 9 10 11 12 13 | $ mkdir Ragtimeblues $ git clone ssh : //192 .168.1.96 /var/repos/git/sandbox .git $ cd sandbox $ git log --oneline 88d4d60 (HEAD -> master, origin /master , origin /HEAD ) add URL description 814a977 add Start date of site 13cc07f add URL efdad3c (origin /develop ) first commit$ git checkout -b develop origin /develop $ git branch -a * master remotes /origin/HEAD -> origin /master remotes /origin/develop remotes /origin/master |
Git使いになろう:ファイル内の変更を部分的にコミットする
ひとつのファイルを更新していて、コミットするときに更新の内容を別々の単位でコミットしたくなる場合があります。
このとき、ファイルを編集しなおしてからコミットする必要はありません。git addをする際に”-p”というオプションを付ければよいです。
元のファイル
1 2 | Ragtimeblues https: //ragtimeblues .net/ |
に対して
1 2 3 4 | Ragtimeblues since 2016.01.01 https: //ragtimeblues .net/ This site is my diary. |
と変更したとします。ここでgit add -pとしてみます。
1 2 3 4 5 6 7 8 9 10 11 | $ git add -p sample.txt diff --git a /sample .txt b /sample .txt index 1e85400..36f88c3 100644 --- a /sample .txt +++ b /sample .txt @@ -1,2 +1,4 @@ Ragtimeblues +since 2016.01.01 https: //ragtimeblues .net/ +This site is my diary. Stage this hunk [y,n,q,a,d,/,s,e,?]? |
このhunk(大きな塊)をステージするかが訊かれます。使い方がわからなければ’?’でヘルプを表示できます。ヘルプを表示してみると、
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | y - stage this hunk n - do not stage this hunk q - quit; do not stage this hunk or any of the remaining ones a - stage this hunk and all later hunks in the file d - do not stage this hunk or any of the later hunks in the file g - select a hunk to go to / - search for a hunk matching the given regex j - leave this hunk undecided, see next undecided hunk J - leave this hunk undecided, see next hunk k - leave this hunk undecided, see previous undecided hunk K - leave this hunk undecided, see previous hunk s - split the current hunk into smaller hunks e - manually edit the current hunk ? - print help |
となりますのでやりたいことを選択すればOKです。