GitをCentosにインストール(install)する
sudo yum remove git
sudo yum install make curl-devel gcc openssl-devel expat-devel cpan gettext asciidoc xmlto
wget https://www.kernel.org/pub/software/scm/git/git-2.15.0.tar.gz
tar -zxf git-2.15.0.tar.gz
cd git-2.15.0
./configure
make prefix=/usr/local/git all
make prefix=/usr/local/git install
sudo make install
tee /etc/profile.d/setGitPath.sh <<-'EOF'
#!/bin/sh
export PATH=/usr/local/git/bin:$PATH
EOF
$ source /etc/profile.d/setGitPath.sh
$ git --version
リモートのブランチにチェックアウト
git checkout -b atlas remotes/origin/atlas
2段階認証が有効になったせいで、git clone できなるなって、下のようなエラーが出る $ git clone git@github.com:idcf-internal/riakcs-storage-calculation.git Initialized empty Git repository in /home/opsadmt/ ssh: connect to host github.com port 22: Network is unreachable fatal: The remote end hung up unexpectedly [opsadmin@deploy ~]$ git clone https://github.com/.....git Initialized empty Git repository in /home/opsadmin/riakcs-storage-calculation/.git/ error: The requested URL returned error: 403 Forbidden while accessing https://gi....
解決策としては ~/.netrcファイルに下のような内容を追加、passwordはTokenになっていることに注意、必要であれば生成する machine github.com login <login_name> password af515ed3853d38 protocol https
Centos 6に新しいgitをインストール
yum install http://opensource.wandisco.com/centos/6/git/x86_64/wandisco-git-release-6-1.noarch.rpm
yum install git -y
master
ブランチはA,B,C
三つのコミットで
master
ブランチからfeature
ブランチを作って、さらに二つX、Y
をコミットする
このときにmaster
にhotfix
が必要で、master
からhotfix
ブランチを作成して、D
をコミットする
master
ブランチに戻って、hotfix
をマージして、master
ブランチにA,B,C,D
四つのコミットがあった。
そしてfeature
ブランチに行って、git rebase master
を実行して、feature
ブランチのコミットは直線のA,B,C,D,X,Y
になる
master
に戻ってfeature
ブランチをマージする
depth=1
を指定するとgit log
の履歴は最新の一個しかない,なので,取得スピードが早い,そのかわりに,push
できない
$ git clone --depth=1 --branch ruby_2_1 --single-branch git@github.com:ruby/ruby.git
特定のtagにcheckout
git clone <repo-address>
git tag -l
git checkout <tag-name>