ラベル git の投稿を表示しています。 すべての投稿を表示
ラベル git の投稿を表示しています。 すべての投稿を表示

2013/11/27

git diff を単語レベルで

これ探し求めとったやつや・・・。TortoiseGitのdiffは単語レベルで表示できてたから、git diffのオプションかな?と思って調べたけど、できなくて諦めてた。

さっそく設定したが、満足である。

2013/09/01

Re: gitのコミットログの集計

改めて探したらいろいろあった。いろいろあるけどほとんどのものはWebUIしかないようだ。個人的にはその仕様は残念だ。その中でgitinspectorというのがコマンドとしても実行できて感触がいい。統計の項目がちょっと物足りないけれど。

2013/07/25

gitのコミットログの集計

普通はどうやって集計してるのかな。コミットログを月間集計などして投げつけたりしてるんですか?誰がどのプロジェクトにどのくらいコミットしてるか毎日投げつけたりしてるんですか?そういう便利なツールがあるんですか?それともshellscript+cronとかですか?

追記

crontabの恐怖

今度からgitで管理するわ・・・。

追記

コメント欄で教えてもらったステキツール。

gitのalias削除

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'

2013/06/11

git logのフォーマット


最近tigも使ってるけど、やっぱりgit logってやることが多いので。
でもaliasはhis...。

2012/06/19

gitでremoteのコミットをなかったことにしたい

今日会社で困ったのでメモ

目的

remoteのコミットをなかったことにしたい

参考にしたのはこちら

基本的に内容は同じ。

シチュエーション

  • 大幅修正
  • commit
  • commit
  • push
  • やっぱ大幅修正前に戻したい
  • コミットもなかったことにしたい

シナリオ

  • ローカルでreset --hard
  • remoteのbranch消す
  • ローカルの状態をpush

方法

取りあえずremoteはoriginでbranchはmasterということで。


branchのバックアップを取る
% git push origin master:master_bak
ローカルのcommitをなかったことにする
% git reset --hard xxxxxxxxxxxx
gitの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を切れるわけか)
remoteで作ったブランチを手元に持ってくるには
% 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

2012/01/30

gitで.ssh/id_rsa以外の鍵を使う(GIT_SSH)

メモし忘れてた。
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.

参考




Gitによるバージョン管理

2012/01/25

github pages

ちょっと前に試しに作ってみてた。 で、リポジトリごとにこういうことができるらしい ので試してみた へぇー。

ということでこれを試してみようかな。 きっかけはこちら

別件

そういえばprivateなリポジトリが作れるbitbucketでしばらく前からgitを使えるということを思い出したのでこっちも試してみた。

2日連続でちょっと遠出しただけで絶賛体調不良中。

2012/01/23

windows server に cygwin 入れて sshd サーバ立てて git サーバにした話

タイトルでほとんど内容終わり。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があるんで使わない手はないかなと。


追記

こういう方法もあるようで。

実用Git

2011/11/20

git

仕事でもプライベートでも使ってきたけどなかなかちゃんと使いこなせない。
それでもすごく便利。
これ知らんかったなー。
--no-ff フラグは、たとえマージがfast-forwardで実行できるとしても、新しいコミットオブジェクトを作成する。これは、履歴にフィーチャーブランチが存在したという情報を失うの\ を避けるのと、機能の追加に使った全てのコミットをひとまとめにしておける。


追記



Gitによるバージョン管理

2011/02/06

bash のプロンプトに git の branch を表示する


昨日の #9LISP@s1mple さんに教えてもらいました。

この辺を参考にやってみました。
これは良い。Emacs の dired もこんな感じにできないかなー。


あとこんなコマンド
$ find . type f -print0 | xargs -0 grep "hoge"
と sl と dyndns を教えてもらった。
ip アドレス直打ちで serversman にアクセスしてたので、ドメインを取ろうか迷ってるって言ったら、無料の ddns サービスで良いんじゃね?みたいな。

追記

git の branch を表示するようにしてから、Emacs の tramp からアクセスできなくなってしまいました。。で、どうやらプロンプトの色が原因のようです。
ls は、端末エミュレーターが色を変更するための ANSI エスケープシークエンスを出力します。しかしながら、このエスケープ シークエンスは TRAMP を混乱させます。
白黒の設定にしたらつながるようになりました・・・。というのもシャクなので、tramp 用のユーザを作りました。というのもシャクなんですけどね。。

bashクックブック

2011/01/31

git-svn

google closure library 入れたり、chaton のサンプルソース読みたいのに sourceforge の Web ソースビューワが動いてなかったり(2011/01/31 現在)で、調べたら git-svn というのがあったので入れました。

こんな感じで使えます。
git svn clone https://chaton.svn.sourceforge.net/svnroot/chaton chaton

便利。
yum から入りました。

実用Git

2010/10/28

gist を blog に embed する時の見た目や色(CSS) を変える

blog に gist を貼り付けることが多いです。見た目を変えたいなぁと思っていたのでやってみました。
参考にしたのはこちら。

色合いは自分の Emacs のハイライトを htmlize.el したものを参考にしてやってみました。やってみたんですが、どうにもクドイので実際にこのまま使うか迷っています。
こんな感じ。


css

用意した css は以下のものです。

余談ですが

Emacs では color-theme.el の midnight を少し変更したものを使っています。
;; 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")))))

Scheme のハイライトは quack.el の pltish を少し変更しています。
;; 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")))))

追記

gist のハイライトの変更は止めました。




Emacsテクニックバイブル ~作業効率をカイゼンする200の技~

2010/07/14

git 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.

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

2010/07/09

git permission denied (publickey) faital: the remote end hung up unexpectedly

最近 gist しか使ってなくて、久しぶりに git の方でコミットしようと思ったら・・・。
$ git push origin master
Permission denied (publickey).
fatal: The remote end hung up unexpectedly


入門Git実用Git

2010/02/24

2010/02/11

gist.el

便利。
gitの方も何か便利なのあるのかな。
M-x gist-buffer
M-x gist-region
M-x gist-buffer-private

書籍

左端の「入門git」の良い評判をよく聞くのですが、若干古くなってきてるらしいですね。
入門git 入門Git 実用Git