LoginSignup
9
9

More than 5 years have passed since last update.

Git初心者向けの初期設定と運用方法

Last updated at Posted at 2014-03-02

CloneからUpstreamの設定まで

  • hogeオーガナイゼーションのfugaリポジトリをcloneする
git clone git@github.com:hoge/fuga.git
Cloning into 'fuga'...
remote: Counting objects: 109, done.
remote: Compressing objects: 100% (70/70), done.
remote: Total 109 (delta 15), reused 109 (delta 15)
Receiving objects: 100% (109/109), 12.34 KiB, done.
Resolving deltas: 100% (15/15), done.    
$ cd fuga
  • リモートリポジトリとして、オリジナルのリポジトリを upstream という名前で設定
$ git remote add upstream git://github.com/fuga/hoge.git

これでリモートblanchの設定は可能

運用方法

  • master もしくは、develop branchにチェックアウトする
git checkout master
もしくは
git checkout develop
  • いまのブランチの状態を確認
git branch -a
  • 不要なローカルブランチを削除する
git branch -d feature/hogehoge
  • リモート上の削除されたブランチをローカルから削除する
git remote prune origin
  • 本家リポジトリの変更を取り出すため、fetchをします
git fetch --all
Fetching origin
Fetching upstream
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (6/6), done.
From github.com:hoge/hoge
   hoge  master     -> upstream/master
  • fetchをしたのをマージします
git merge upstream/master
Updating hoge
Fast-forward
  • featureブランチを作成
git checkout -b feature/hogehoge

ツールの設定

bash で git コマンドのブランチ名などを補完してくれるgit-completion.bash を導入する。

  • git/contrib/completion/git-completion.bash をダウンロードして適当な場所に配置(例えば ~/.git-completion.bash)
    • home brewでgitをインストールしていたら/Users/your/brew/etc/bash_completion.d にある
  • ~/.bashrc に source ~/.git-completion.bash の一行を加える

参考

http://qiita.com/xtetsuji/items/555a1ef19ed21ee42873
http://qiita.com/snaka/items/4b0437a32da832d2e0db

9
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9