Skip to content

Instantly share code, notes, and snippets.

@wang-zhijun
Last active November 1, 2017 07:07
Show Gist options
  • Save wang-zhijun/f089b8c6ff6e586210551a3fcf5be596 to your computer and use it in GitHub Desktop.
Save wang-zhijun/f089b8c6ff6e586210551a3fcf5be596 to your computer and use it in GitHub Desktop.
Git

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

rebase

masterブランチはA,B,C三つのコミットで

masterブランチからfeatureブランチを作って、さらに二つX、Yをコミットする

このときにmasterhotfixが必要で、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

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment