Skip to content

Instantly share code, notes, and snippets.

@Milly
Forked from xyzzy-17-638/gist:1992293
Created June 13, 2012 15:30

Revisions

  1. Milly revised this gist Jun 13, 2012. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ Gitチートシート
    ===============

    [msysGit](http://code.google.com/p/msysgit/)をインストール後、
    「スタート」「Git」「Git Bash」を実行して Git Bash を立ち上げ、
    「スタート」>「Git」>「Git Bash」を実行して Git Bash を立ち上げ、
    以下のコマンドを実行することで、さまざまな作業を行えます


    @@ -102,7 +102,7 @@ Gitチートシート
    $ git checkout ブランチ名
    $ git checkout -b まとめブランチ名
    $ git rebase -i master
    ここで、vi が開くので、2行目以降の行頭の pick を squash に変更する
    <ここで、vi が開くので、2行目以降の行頭の pick を squash に変更する>
    $ git push origin まとめブランチ名
    ```
    - GitHub にあるブランチ一覧を見る
    @@ -129,4 +129,8 @@ Gitチートシート

    - タグ名-タグから最新までのコミット数-g最新のコミットハッシュ値 (GitHubでのzipballの名前の後半はこれを用いている)

    $ git describe --tags --dirty --long
    $ git describe --tags --dirty --long

    - ログのツリー表示

    $ git log --graph --decorate --pretty=oneline --abbrev-commit
  2. @xyzzy-17-638 xyzzy-17-638 revised this gist May 21, 2012. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -28,10 +28,10 @@ Gitチートシート
    $ git config user.name "ユーザ名"
    $ git config user.email "メールアドレス"

    - エディタを設定する (C:\app\xyzzy\xyzzy.exe)
    - エディタを設定する (C:\app\xyzzy\xyzzy.exe) - ただし、この設定だと日本語が使えない :(

    $ cd /c/github/xyzzy
    $ git config core.editor "/c/app/xyzzy/xyzzy.exe"
    $ git config core.editor "start //wait /c/app/xyzzy/xyzzycli.exe -wait"

    ## 日常の操作

    @@ -129,4 +129,4 @@ Gitチートシート

    - タグ名-タグから最新までのコミット数-g最新のコミットハッシュ値 (GitHubでのzipballの名前の後半はこれを用いている)

    $ git describe --tags --dirty --long
    $ git describe --tags --dirty --long
  3. @xyzzy-17-638 xyzzy-17-638 revised this gist May 6, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -127,6 +127,6 @@ Gitチートシート

    $ git describe --tags --dirty --abbrev=0

    - タグ名+コミット数+コミットハッシュ値 (GitHubでのzipballの名前の後半はこれを用いている)
    - タグ名-タグから最新までのコミット数-g最新のコミットハッシュ値 (GitHubでのzipballの名前の後半はこれを用いている)

    $ git describe --tags --dirty --long
    $ git describe --tags --dirty --long
  4. @xyzzy-17-638 xyzzy-17-638 revised this gist May 6, 2012. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -117,16 +117,16 @@ Gitチートシート

    - タグ一覧

    $ git tag -l
    $ git tag -l

    - タグプッシュ

    $ git push --tags
    $ git push --tags

    - 直近のタグ名

    $ git describe --tags --dirty --abbrev=0
    $ git describe --tags --dirty --abbrev=0

    - タグ名+コミット数+コミットハッシュ値 (GitHubでのzipballの名前の後半はこれを用いている)

    $ git describe --tags --dirty --long
    $ git describe --tags --dirty --long
  5. @xyzzy-17-638 xyzzy-17-638 revised this gist May 6, 2012. 1 changed file with 4 additions and 12 deletions.
    16 changes: 4 additions & 12 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -115,26 +115,18 @@ Gitチートシート
    $ cd /c/github/xyzzy
    $ git push origin :ブランチ名

    - タグ一覧
    - タグ一覧

    ```
    $ git tag -l
    ```

    - タグプッシュ
    - タグプッシュ

    ```
    $ git push --tags
    ```

    - 直近のタグ名
    - 直近のタグ名

    ```
    $ git describe --tags --dirty --abbrev=0
    ```

    - タグ名+コミット数+コミットハッシュ値 (GitHubでのzipballの名前の後半はこれを用いている)
    - タグ名+コミット数+コミットハッシュ値 (GitHubでのzipballの名前の後半はこれを用いている)

    ```
    $ git describe --tags --dirty --long
    ```
  6. @xyzzy-17-638 xyzzy-17-638 revised this gist May 6, 2012. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -115,19 +115,26 @@ Gitチートシート
    $ cd /c/github/xyzzy
    $ git push origin :ブランチ名


    - タグ一覧

    ```
    $ git tag -l
    ```

    - タグプッシュ

    ```
    $ git push --tags
    ```

    - 直近のタグ名

    ```
    $ git describe --tags --dirty --abbrev=0
    ```

    - タグ名+コミット数+コミットハッシュ値 (GitHubでのzipballの名前の後半はこれを用いている)

    ```
    $ git describe --tags --dirty --long
    ```
  7. @xyzzy-17-638 xyzzy-17-638 revised this gist May 6, 2012. 1 changed file with 18 additions and 1 deletion.
    19 changes: 18 additions & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -113,4 +113,21 @@ Gitチートシート
    - GitHub にあるブランチを消す

    $ cd /c/github/xyzzy
    $ git push origin :ブランチ名
    $ git push origin :ブランチ名


    - タグ一覧

    $ git tag -l

    - タグプッシュ

    $ git push --tags

    - 直近のタグ名

    $ git describe --tags --dirty --abbrev=0

    - タグ名+コミット数+コミットハッシュ値 (GitHubでのzipballの名前の後半はこれを用いている)

    $ git describe --tags --dirty --long
  8. @xyzzy-17-638 xyzzy-17-638 revised this gist May 5, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -97,14 +97,14 @@ Gitチートシート
    $ git branch -d ブランチ名

    - Pull Request 用に、コミットを 1 つにまとめて GitHub に push する

    ```
    $ cd /c/github/xyzzy
    $ git checkout ブランチ名
    $ git checkout -b まとめブランチ名
    $ git rebase -i master
    <ここで、vi が開くので、2行目以降の行頭の pick を squash に変更する>
    $ git push origin まとめブランチ名

    ```
    - GitHub にあるブランチ一覧を見る

    $ cd /c/github/xyzzy
  9. @xyzzy-17-638 xyzzy-17-638 revised this gist May 5, 2012. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -9,8 +9,8 @@ Gitチートシート
    ## 簡単な用語集

    - master : ローカルの master ブランチ
    - origin : GitHub上の自分の clone したリポジトリのこと
    - origin/master : GitHub上の自分の clone したリポジトリの master ブランチ
    - origin : GitHub上の自分の clone 元のリポジトリのこと
    - origin/master : GitHub上の自分の clone 元のリポジトリの master ブランチ
    - upstream : GitHub上のFork元のリポジトリのこと
    - upstream/master : GitHub上のFork元のリポジトリの master ブランチ

    @@ -113,4 +113,4 @@ Gitチートシート
    - GitHub にあるブランチを消す

    $ cd /c/github/xyzzy
    $ git push origin :ブランチ名
    $ git push origin :ブランチ名
  10. @xyzzy-17-638 xyzzy-17-638 created this gist Mar 7, 2012.
    116 changes: 116 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,116 @@
    Gitチートシート
    ===============

    [msysGit](http://code.google.com/p/msysgit/)をインストール後、
    「スタート」>「Git」>「Git Bash」を実行して Git Bash を立ち上げ、
    以下のコマンドを実行することで、さまざまな作業を行えます


    ## 簡単な用語集

    - master : ローカルの master ブランチ
    - origin : GitHub上の自分の clone したリポジトリのこと
    - origin/master : GitHub上の自分の clone したリポジトリの master ブランチ
    - upstream : GitHub上のFork元のリポジトリのこと
    - upstream/master : GitHub上のFork元のリポジトリの master ブランチ


    ## 初期設定

    - upstream (Fork元) を設定する

    $ cd /c/github/xyzzy
    $ git remote add upstream https://github.com/mumurik/xyzzy.git

    - ユーザ名、メールアドレスを設定する

    $ cd /c/github/xyzzy
    $ git config user.name "ユーザ名"
    $ git config user.email "メールアドレス"

    - エディタを設定する (C:\app\xyzzy\xyzzy.exe)

    $ cd /c/github/xyzzy
    $ git config core.editor "/c/app/xyzzy/xyzzy.exe"

    ## 日常の操作

    - 間違ったので、直前の commit を取り消したい

    $ cd /c/github/xyzzy
    $ git reset --hard HEAD^

    - とにかく**何もかも消して**、upstream/master と同じ状態に戻したい

    $ cd /c/github/xyzzy
    $ git checkout master
    $ git reset --hard upstream/master
    $ git clean -fdx

    - ローカルの作業コピー (master) を Fork 元 (upstream/master) に合わせる

    $ cd /c/github/xyzzy
    $ git stash
    $ git fetch upstream
    $ git rebase upstream/master master
    $ git stash pop

    - ローカルの作業コピー (master) を GitHub にアップロード (push) する

    $ cd /c/github/xyzzy
    $ git push origin master

    - master をもとに、ブランチを作る

    $ cd /c/github/xyzzy
    $ git checkout master
    $ git checkout -b ブランチ名

    - ブランチの切り替え

    $ cd /c/github/xyzzy
    $ git checkout ブランチ名

    - ローカルのブランチと master を upstream に合わせる

    $ cd /c/github/xyzzy
    $ git stash
    $ git fetch upstream
    $ git rebase upstream/master master
    $ git rebase master ブランチ名
    $ git stash pop

    - ローカルのブランチを GitHub に push する

    $ cd /c/github/xyzzy
    $ git push -f origin ブランチ名

    - ローカルのブランチ一覧を見る

    $ cd /c/github/xyzzy
    $ git branch

    - ローカルのブランチを消す

    $ cd /c/github/xyzzy
    $ git checkout master
    $ git branch -d ブランチ名

    - Pull Request 用に、コミットを 1 つにまとめて GitHub に push する

    $ cd /c/github/xyzzy
    $ git checkout ブランチ名
    $ git checkout -b まとめブランチ名
    $ git rebase -i master
    <ここで、vi が開くので、2行目以降の行頭の pick を squash に変更する>
    $ git push origin まとめブランチ名

    - GitHub にあるブランチ一覧を見る

    $ cd /c/github/xyzzy
    $ git branch -r

    - GitHub にあるブランチを消す

    $ cd /c/github/xyzzy
    $ git push origin :ブランチ名