• opsだけどgitを使ってみた~その2

    こんにちは。小宮です。 前回のつづきです。今回はgitマージとタグとコンフリクトの話を書きます。 まあ初心者が慣れてきた頃の様子ということで生温かく見守ってください。 git-flowやブランチモデルがどうという話はでてきません。

    git branch でブランチを切る

    現在居る場所を確認する

    $ git branch -a
      add_custom_repository
    * master
    

    addしただけのやつがないのを確認します。

    $ git status
    # On branch master
    # Changed but not updated:
    #   (use "git add <file>..." to update what will be committed)
    #   (use "git checkout -- <file>..." to discard changes in working directory)
    #
    #       modified:   .gitignore
    #
    no changes added to commit (use "git add" and/or "git commit -a")   
    

    ※万が一addしただけのやつがある場合、commitするかstashするかする必要があります。

    ...
  • remotediff

    各環境間での /etc/hosts をdiffする場合のmemo

    Cloud上でサーバを大量に作成したあと、confの比較チェックするときなどに。

     

    ・ローカル同士(/etc/hosts.backupと比較)

    $ diff /etc/hosts /etc/hosts.backup
    

     

    ・ローカル<->リモート(xxx-web01)

    $ diff /etc/hosts <(ssh xxx-web01 cat /etc/hosts)
    

     

    ・リモート(xxx-web01) <-> リモート(xxx-web02)

    $ diff <(ssh xxx-web01 cat /etc/hosts) <(ssh xxx-web02 cat /etc/hosts)
    

     

    ・ローカル<->リモートで復数サーバ(xxx-web01~10)

    $ for SRV in xxx-web0{1..9} xxx-web10
    > do
    > echo ${SRV}
    > diff /etc/hosts <(ssh ${SRV} cat /etc/hosts)
    > done
    

     

    ...