GitUsage - osakichi/memo GitHub Wiki
以下の内容はGitのバージョンが上がると不要になるものもあるかも
git clone https://devportal.kamome/git/hoge.git
編集&git add
git commit
git push
git pull
git config --global user.email "[email protected]"
git config --global user.name "Kohji Osamura"
指定しないと日本語ファイル名は扱えても正しく表示されない
git config --global core.quotepath false
httpsアクセスでオレオレ証明書が使われている場合 sshアクセスでは不要
git config --global http.sslVerify false
git-credential-storeを使う(平文でファイルに保存する)
git config --global credential.helper store
git-credential-cacheを使う(一時的にメモリにキャッシュする)
git config --global credential.helper 'cache --timeout=72000'
他にもいろいろある(wincred
とかosxkeychain
とかlibsecret
とか)
ただし使えるのはバージョン1.7.9以降。
これより古い場合は.netrc
を使う方法しかない。
リポジトリサーバ上で以下を実行
git init --bare --shared hoge.git
あるリポジトリから別のリポジトリに中身をまるっと移す場合は、
--mirror
オプションを使って以下の手順で行う。
git clone --mirror <移行元リポジトリURL> <ローカルコピー名>
cd <ローカルコピー名>
git push --mirror <移行先リポジトリURL>
例えば以下のような感じ。
git clone --mirror https://github.com/kamome-e/old-hoge.git hoge
cd hoge
git push --mirror https://github.com/kamome-e/new-hoge.git
ローカルコピー名は移行先リポジトリ名と同じでも異なっていても良い。 移行先にはあらかじめ空のリポジトリを作っておくこと。
リモートリポジトリ上で実行。以下をひとつづつ試し、効果がなければ次を試す。
git gc
git gc --aggressive
git repack -a -f -d --window=250 --depth=250
git config http.postBuffer 24288000
Git-it - 手を動かしながら習得できる日本語対応のGit/GitHub学習アプリ git-it
-
ユーザ名の@ Git URLでメールアドレス形式のユーザ名を指定する場合、以下のようにURLエスケープを使うと上手くいくっぽい。
git clone 'https://umino%[email protected]/git/hoge.git'
↑で ちゃんと[email protected]
というユーザ名で処理される。 -
コメント 1行目にsummary, 2行目は空行, 3行目以降に詳細 を書くのがよいらしい(GitHubだけ?) gitコマンドで複数行をコメントするときは、1行ごとに-mオプションをつけるらしいよ
git commit -m "コメントその1summary" -m "" -m "コメントその2discription"
↓こんな感じになる。
[osakichi hello-world]$ git log
commit 90b01620d0c83c7c7453a5592fb2b7bb5f65f1ad
Author: Kohji Osamura <[email protected]>
Date: Thu Jan 5 16:33:16 2017 +0900
コメントその1summary
コメントその2discription
GitHub Desktopを使うと、summaryとdiscriptionの入力欄が分かれてるので、それに従えばOK。(上記のようにくっついた感じになる)
- git diffいろいろ
修正した量のサマリーだけ欲しい
⇒こんな感じで
--shortstat
オプションを使う。
git diff --shortstat <比較元リビジョン> <比較先リビジョン>
127 files changed, 1363 insertions(+), 202 deletions(-)
特定ディレクトリやファイルのdiffだけ見たい
⇒コマンドの後ろに--
で区切ってディレクトリ/ファイルを指定する。
git diff <比較元リビジョン> <比較先リビジョン> -- <ディレクトリ/ファイル名>
--- a/openam-oauth2/openam-oauth2-common/src/main/java/org/forgerock/openam/oauth2/utils/OAuth2Utils.java
+++ b/openam-oauth2/openam-oauth2-common/src/main/java/org/forgerock/openam/oauth2/utils/OAuth2Utils.java
@@ -859,11 +859,13 @@ public class OAuth2Utils {
theID = results.iterator().next();
- //if the client is deactivated return null
+ //if the client is deactivated throws Exception
:
特定ファイルをdiffから除外したい
⇒リポジトリトップ(.gitignore
とかを置く場所)に.gitattributes
というファイルを置き、
以下の感じで除外したいファイルを記述する。
vi <リポジトリトップ>/.gitattributes
cat <リポジトリトップ>/.gitattributes
Makefile -diff
pom.xml -diff
.gitattributes
は他にもいろいろ使えそう。