揮発性のメモ2

http://d.hatena.ne.jp/iww/

git

gitで リポジトリを確認する

git

git でリポジトリを確認するにはremote -vコマンドを使う $ git remote origin $ git remote -v origin ssh://hoge@192.168.0.10/var/lib/git/piyopiyo.git (fetch) origin ssh://hoge@192.168.0.10/var/lib/git/piyopiyo.git (push) Git - git-remote Docum…

SourceTreeでfetchできない 2

iww.hateblo.jp SourceTreeがアホで、puttyからの問い合わせのキー入力待ちで無限に止まるバグに対する対処の話今どきのSourceTreeは、なんか違うところにインストールされているので、まずそこから /c/Users/hogehoge/AppData/Local/SourceTree hogehogeユ…

git push でエラーがでたとき

git

git push でエラーが出たとき hint: Updates were rejected because the tag already exists in the remote.リモート側とこっち側とで、同名だけど別のタグがあるとエラーになるらしい。 【SourceTree】プッシュしようとすると、「Updates were rejected bec…

gitで、過去からブランチを切ってたことにしたい

git

gitで、ブランチを切り忘れて作業してたので過去からブランチを切ってたことにしたい。 ブランチHOGEのAから分岐してPIYOを作成するのが普通だけど、 BとCの修正は実はPIYOだった風に見せたい。 そもそもこんなことできるのかな

gitで、最新のファイルだけ全部cloneする

git

git clone -b master --single-branch --depth 1 --recursive --shallow-submodules https://gitlab.com/hogehoge/hogehoge.git -b master ブランチ指定 (例ではmasterを指定) --simgle-branch 指定したブランチだけclone --depth 1 1階層(最新)だけclone …

fatal: protocol error: expected old/new/ref, got 'shallow

fatal: protocol error: expected old/new/ref, got 'shallow xxxxxxxxx' fatal: The remote end hung up unexpectedly fatal: The remote end hung up unexpectedlyシャローなクローンをしたリポジトリをプッシュしたときのエラー。クローン元のgitのバージ…

SourceTreeでCloneすると改行がCRLFになってしまう

git for windowsのデフォルト設定がアホで、改行の自動変更がわざわざ有効に設定されている。 最初sourcetreeのバグかと思って苦労した。気を付けたい。 [core] ; autocrlf = true autocrlf = false

.gitignore で拡張子のない実行バイナリを管理対象外にする

git

ファイル名にプレフィックスがついててそれで判別できるときは hoge_* !*.h !*.cのように書くことであらかじめ対象外にできる。

gitでconfigのそれぞれの変数を見る

git

configで見れる $ git config core.filemode true 設定していないのでデフォルトを見たいときや 反する設定を重ねていて結局今は何になってるかわからないとき に使う

特定のファイルを管理対象から外す

git

ファイルを残したまま管理対象から外すときは git rm --cached ファイル名SourceTreeでやるときは右クリックメニューから「追跡をやめる」を選択

SourceTreeでfetchできない

git

ある開発環境の作業ディレクトリをまるっとコピーして別PCで開発をはじめようとしたとき、SourceTreeでfetchやpushをしようとすると無限に待たされる。 内部で使用しているPuTTYが問い合わせをおこなってきてて、無限に待たされているらしい。 内部で使用し…

Git for Windows インストール 注意事項

http://www.webhack.jp/tool/phpstorm-cannot-run-program-git-exe WindowsにおけるGit利用環境は整った: Git for Windows と SourceTree for Windows - 檜山正幸のキマイラ飼育記 Redirecting Git for Windows' homepage... (Git-1.9.5-preview20150319.ex…

SourceTree Windows版で文字化けが起こる 問題の解決

Windows版のSourceTreeで、文字コードUTF-8のファイルで、なんでか特定のファイルだけ文字化けが起こる。 http://www.tokyo-web.jp/news/archives/sourcetree-windowsutf8bom.html どうも、BOMをつけていれば問題ないらしい。 しかしPHPファイルでBOMなんて…

git stash

git

# やりかけの作業を退避 git stash # fetchしてmerge git pull # 退避してた分をマージ git stash pop

git でfatalエラーが出たとき

git

ファイルが壊れたりしたときに発生することがあるらしい。 $ git status fatal: loose object xxxxxxx (stored in .git/objects/xx/xxxxxxx) is corruptこの .git/objects/xx/xxxxxxx ってファイルを消して、fetchしなおせば大体解決する

gitでディレクトリ名を変更する

git

gitコマンドでディレクトリ名を変更する git mv hoge piyo

git cloneでout of memoryになる

git

$ git clone ssh://hoge@piyo/var/lib/git/fuga.git Cloning into fuga... remote: Counting objects: 1466, done. remote: warning: suboptimal pack - out of memory remote: Compressing objects: 82% (358/434) error: pack-objects died of signal erro…

gitのaliasの一覧を表示する

git

[alias] alias = !"f(){ git config --get-regexp alias|cut -d'.' -f2|if [ -z $1 ];then cut -d' ' -f1|column; else grep $1' '; fi }; f" .gitconfigに書いたエイリアスの一覧表示と詳細表示のコマンドを表示するエイリアス 使い方: 一覧表示 $ git alia…

warning: refname 'HEAD' is ambiguous.

git

「HEADって名前がなんかあいまい」 ってエラー出た。 $ git status warning: refname 'HEAD' is ambiguous. warning: refname 'HEAD' is ambiguous. # On branch master nothing to commit (working directory clean) [git] ブランチ、タグ、その他リファレ…

error: git upload-pack: git-pack-objects died with error.

git

$ git clone jikken@testserver:/var/lib/git/TESTPROJECT.git Cloning into TESTPROJECT... remote: Counting objects: 1365, done. remote: Compressing objects: 78% (623/790)$ git clone jikken@testserver:/var/lib/git/TESTPROJECT.git Cloning into …

cvsからgitへのコマンドごとの読み替え

git

やること cvs git リポジトリ置場 /var/lib/cvs /var/lib/git インポート(新規作成) cd projectcvs import project vendor tagnamecd ../rm -rf projectcvs co project ssh user@server 'mkdir /var/lib/git/project.gitcd /var/lib/git/project.gitgit init…

gitのdiffに色をつける

git

colordiff使わなくてもきれいに色が付いてた [悪徳商法?支店]: gitに色をつける ~/.gitconfig はこんな感じ [user] name = hoge email = hoge@example.com [core] pager = cat [color] status = auto diff = auto branch = auto interactive = auto pagerに…

git config --global core.pager colordiff

ページャーとかいらないけど差分表示したときに勝手に色をつけてほしいので ここを参考に $ git config --global core.pager colordiff~/.gitconfig [core] pager = colordiff

gitのタイムスタンプをコミット時の時刻にする

本当はオリジナルのタイムスタンプを復元したいんだけど、それは失われるらしい http://stackoverflow.com/questions/2179722/checking-out-old-file-with-original-create-modified-timestamps このスクリプトが何用かわからなかったので、改造して使えるよ…