これ探し求めとったやつや・・・。TortoiseGitのdiffは単語レベルで表示できてたから、git diffのオプションかな?と思って調べたけど、できなくて諦めてた。
さっそく設定したが、満足である。
これ探し求めとったやつや・・・。TortoiseGitのdiffは単語レベルで表示できてたから、git diffのオプションかな?と思って調べたけど、できなくて諦めてた。
さっそく設定したが、満足である。
改めて探したらいろいろあった。いろいろあるけどほとんどのものはWebUIしかないようだ。個人的にはその仕様は残念だ。その中でgitinspectorというのがコマンドとしても実行できて感触がいい。統計の項目がちょっと物足りないけれど。
普通はどうやって集計してるのかな。コミットログを月間集計などして投げつけたりしてるんですか?誰がどのプロジェクトにどのくらいコミットしてるか毎日投げつけたりしてるんですか?そういう便利なツールがあるんですか?それともshellscript+cronとかですか?
git config --global --unset alias.myAlias
以下すべて余談だけど、gitに限らずshellでもあまりaliasは設定しない。人によってはかなりいろいろ設定するらしいですが、他の環境で困りません?.zshrc確認したらこんだけだった。
alias screen='screen -S main -UxRL' alias ls='ls --color=always' alias rm='rm -i' alias mv='mv -i' alias hd='hexdump' alias diff='colordiff -u' alias rlwrap='rlwrap -pCYAN' alias less='less -R' alias grep='grep --color=always'
今日会社で困ったのでメモ
remoteのコミットをなかったことにしたい
参考にしたのはこちら
基本的に内容は同じ。取りあえずremoteはoriginでbranchはmasterということで。
% git push origin master:master_bakローカルのcommitをなかったことにする
% git reset --hard xxxxxxxxxxxxgitのremote branchを削除
% git push origin :masterローカルのmasterをpush
% git push origin master
% git push -f origin xxxxxxxxxxxxx:master
% git push origin master:master_bakこれでremoteのbranchのバックアップが取れるとは。(というかremoteのbranchを切れるわけか)
% git checkout -b master_bak origin/master_bakでいいんだな。
% git push origin :masterのとこで
remote: error: By default, deleting the current branch is denied, because the next remote: error: 'git clone' won't result in any file checked out, causing confusion. remote: error: remote: error: You can set 'receive.denyDeleteCurrent' configuration variable to remote: error: 'warn' or 'ignore' in the remote repository to allow deleting the remote: error: current branch, with or without a warning message. remote: error: remote: error: To squelch this message, you can set it to 'refuse'. remote: error: refusing to delete the current branch: refs/heads/masterみたいなメッセージが出る。その時はremoteのconfigに
[receive]
denyDeleteCurrent = false
を追加してやるといいっぽい。
valvallow@ubuntu ~ % cd temp
valvallow@ubuntu ~/temp % mkdir -p playground/{repo,local}
valvallow@ubuntu ~/temp/playground/repo
% git init --bare
Initialized empty Git repository in /home/valvallow/temp/playground/repo/
valvallow@ubuntu ~/temp/playground/repo
% cd ../local
valvallow@ubuntu ~/temp/playground/local
% git init
Initialized empty Git repository in /home/valvallow/temp/playground/local/.git/
valvallow@ubuntu ~/temp/playground/local
% touch hoge
valvallow@ubuntu ~/temp/playground/local
% echo 'Hello, world !!' > hoge
valvallow@ubuntu ~/temp/playground/local
% git add .
valvallow@ubuntu ~/temp/playground/local
% git commit -m 'initial commit'
[master (root-commit) 1876f96] initial commit
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 hoge
valvallow@ubuntu ~/temp/playground/local
% echo 'add new row' >> hoge
valvallow@ubuntu ~/temp/playground/local
% git add .
valvallow@ubuntu ~/temp/playground/local
% git commit -m 'add new row'
[master e532dc4] add new row
1 files changed, 1 insertions(+), 0 deletions(-)
valvallow@ubuntu ~/temp/playground/local
% echo 'piyo' >> hoge
valvallow@ubuntu ~/temp/playground/local
% git add .
valvallow@ubuntu ~/temp/playground/local
% git commit -m 'piyo'
[master 5e0355c] piyo
1 files changed, 1 insertions(+), 0 deletions(-)
valvallow@ubuntu ~/temp/playground/local
% git remote add origin ../repo
valvallow@ubuntu ~/temp/playground/local
% git push origin master
Counting objects: 9, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (9/9), 688 bytes, done.
Total 9 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (9/9), done.
To ../repo
* [new branch] master -> master
valvallow@ubuntu ~/temp/playground/local
% git branch -a
* master
remotes/origin/master
valvallow@ubuntu ~/temp/playground/local
% git push origin master:master_bak
Total 0 (delta 0), reused 0 (delta 0)
To ../repo
* [new branch] master -> master_bak
valvallow@ubuntu ~/temp/playground/local
% git branch -a
* master
remotes/origin/master
remotes/origin/master_bak
valvallow@ubuntu ~/temp/playground/local
% git branch
* master
valvallow@ubuntu ~/temp/playground/local
% git checkout -b master_bak origin/master_bak
Branch master_bak set up to track remote branch master_bak from origin.
Switched to a new branch 'master_bak'
valvallow@ubuntu ~/temp/playground/local
% git branch
master
* master_bak
valvallow@ubuntu ~/temp/playground/local
% cat hoge
Hello, world !!
add new row
piyo
valvallow@ubuntu ~/temp/playground/local
% git push origin :master
To ../repo
- [deleted] master
valvallow@ubuntu ~/temp/playground/local
% git log
commit 5e0355cb325a8ed90fe066131c72dead9faba329
Author: valvallow
Date: Tue Jun 19 22:23:50 2012 +0900
piyo
commit e532dc4dc21f72292e2a700e28ed544d31c21a31
Author: valvallow
Date: Tue Jun 19 22:23:17 2012 +0900
add new row
commit 1876f96ff3186b5082c9c32e4ed310ac8d4b8a9a
Author: valvallow
Date: Tue Jun 19 22:22:39 2012 +0900
initial commit
valvallow@ubuntu ~/temp/playground/local
% git reset --hard e532dc4dc21f72292e2a700e28ed544d31c21a31
HEAD is now at e532dc4 add new row
valvallow@ubuntu ~/temp/playground/local
% git log
commit e532dc4dc21f72292e2a700e28ed544d31c21a31
Author: valvallow
Date: Tue Jun 19 22:23:17 2012 +0900
add new row
commit 1876f96ff3186b5082c9c32e4ed310ac8d4b8a9a
Author: valvallow
Date: Tue Jun 19 22:22:39 2012 +0900
initial commit
valvallow@ubuntu ~/temp/playground/local
% git push origin master
Total 0 (delta 0), reused 0 (delta 0)
To ../repo
* [new branch] master -> master
valvallow@ubuntu ~/temp/playground/local
% git log
commit e532dc4dc21f72292e2a700e28ed544d31c21a31
Author: valvallow
Date: Tue Jun 19 22:23:17 2012 +0900
add new row
commit 1876f96ff3186b5082c9c32e4ed310ac8d4b8a9a
Author: valvallow
Date: Tue Jun 19 22:22:39 2012 +0900
initial commit
valvallow@ubuntu ~/temp $ cat ~/temp/git_ssh/work #!/bin/sh exec ssh -o User=valvallow -o IdentityFile=/home/valvallow/.ssh/work/id_rsa "$@" valvallow@ubuntu ~/temp $ export GIT_SSH="/home/valvallow/temp/git_ssh/work" valvallow@ubuntu ~/temp $ mkdir test && cd test valvallow@ubuntu ~/temp/test $ git clone valvallow@server:/repos/test-git.git Cloning into test-git... Enter passphrase for key '/home/valvallow/.ssh/work/id_rsa': remote: Counting objects: 44, done. remote: Compressing objects: 100% (43/43), done. remote: Total 44 (delta 21), reused 0 (delta 0) Receiving objects: 100% (44/44), 782.50 KiB | 666 KiB/s, done. Resolving deltas: 100% (21/21), done.
タイトルでほとんど内容終わり。windows 2008 serverでもcygwinって普通に使えるんですね。ちょっと驚いた。
linuxでやるより面倒だったけど、意外となんとかなるもんで。今回はWindows Server 2008。サーバはgit入れてsshd立てて外から接続できれば終わり。つまり、cygwinのsetup.exeもしくはapt-cygなどからOpenSSHとgitをインストール。もちろんfirewallでsshのポートの許可も必要。
これで家でも外出先でも手軽に会社のgitサーバーに対してpush/pullできますよっと。ただ環境作ってる途中、GIT_SSHで少しハマった。cygwinだけなら簡単なんだが、クライアントでGUIからgitを使う、visual studioで使う、という前提で環境作ると面倒、大変、わかりにくい。ところがあった。shellの方が快適ですね。
しかし、意外とちゃんと動くもんで。cygwinやるじゃん。
ちょっと設定変更したらハマった。復旧に数時間。。この辺のエラー
ssh_exchange_identification Connection closed by 192.168.1.xxx ssh_exchange_identification: Connection closed by remote host cygrunsrv: Error starting a service: QueryServiceStatus: Win32 error 1062: fatal: /var/empty must be owned by root and not group or world-writable Operation not permitted
今回はこれで解決した。
% cygrunsrv -E sshd % cygrunsrv -R sshd % cygrunsrv --install sshd --path /usr/sbin/sshd -a -D -u cyg_server % cygrunsrv -S sshd % chown cyg_server /var/empty % chmod 700 /var/empty
linuxならsshの設定してパッケージマネージャからgit入れるだけなんだけどね。あいにく会社にlinuxサーバーがなくて、windows server 2008があるんで使わない手はないかなと。
こういう方法もあるようで。
--no-ff フラグは、たとえマージがfast-forwardで実行できるとしても、新しいコミットオブジェクトを作成する。これは、履歴にフィーチャーブランチが存在したという情報を失うの\ を避けるのと、機能の追加に使った全てのコミットをひとまとめにしておける。
$ find . type f -print0 | xargs -0 grep "hoge"と sl と dyndns を教えてもらった。
ls は、端末エミュレーターが色を変更するための ANSI エスケープシークエンスを出力します。しかしながら、このエスケープ シークエンスは TRAMP を混乱させます。白黒の設定にしたらつながるようになりました・・・。というのもシャクなので、tramp 用のユーザを作りました。というのもシャクなんですけどね。。
git svn clone https://chaton.svn.sourceforge.net/svnroot/chaton chaton
;; color theme (require 'color-theme nil t) (color-theme-initialize) (color-theme-midnight) (set-face-background 'region "blue4") (set-face-background 'trailing-whitespace "purple4") (set-face-background 'modeline-buffer-id "grey5") (set-face-foreground 'modeline-buffer-id "maroon2") (set-face-background 'mode-line "grey20") (set-face-foreground 'mode-line "grey75") (set-face-background 'mode-line-inactive "grey3") (set-face-foreground 'mode-line-inactive "grey35") (set-face-background 'secondary-selection "red") (set-face-underline-p 'modeline nil) (custom-set-faces '(font-lock-comment-face ((t (:italic nil :foreground "slate gray")))))
;; quack (custom-set-faces '(quack-pltish-keyword-face ((t (:bold t :foreground "maroon2")))) '(quack-pltish-defn-face ((t (:bold t :foreground "darkgoldenrod3")))) '(quack-threesemi-semi-face ((t (:bold t :foreground "blue")))) '(quack-threesemi-text-face ((t (:bold t :foreground "blue")))))
error: failed to push some refs to '[email protected]:foo/hoge.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'non-fast forward'
section of 'git push --help' for details.
作業用ブランチ作る
git branch temp1 git checkout temp1
作業用ブランチにpullする
git pull origin +master:temp1
作業用ブランチとmasterブランチの差分を確認する
git diff temp1 master
masterブランチに作業用ブランチの内容をマージする
git checkout master git merge temp1
$ git push origin master
Permission denied (publickey).
fatal: The remote end hung up unexpectedly