顯示具有 git 標籤的文章。 顯示所有文章
顯示具有 git 標籤的文章。 顯示所有文章

2015年3月26日 星期四

download subdirectory from GitHub

            https://github.com/Username/Repository/tree/master/subdirectory
                                                    |
                                                    v
svn checkout https://github.com/Username/Repository/trunk/subdirectory




References :
Cloning only a subdirectory with git - Stack Overflow

2015年1月18日 星期日

Git remove subtree

$ git filter-branch --index-filter 'git rm --cached --ignore-unmatch -rf dir1 dir2 dirN file1 file2 fileN' --prune-empty -f HEAD
 
 
 
 
References :
How to remove previously added git subtree and its history - Stack Overflow

2014年12月16日 星期二

git push to non bare repository

$ git config --bool receive.denyCurrentBranch false

$ vi .git/hooks/post-receive
# Update working tree after receiving pushed branch
echo "*****************************************************"
echo "Post-receive hook: updating remote working directory"
echo "*****************************************************"
cd ..
env -i git reset --hard

$ chmod +x .git/hooks/post-receive




References :
Quick 'n' Dirty Git Deployment

2014年11月11日 星期二

Git https verify error

fatal: unable to access 'https://github.com/pozgo/docker-snmpd.git/': Problem with the SSL CA cert (path? access rights?)

$ export GIT_SSL_NO_VERIFY=true
$ git clone https://github.com/pozgo/docker-snmpd.git/




References :
git - SSL certificate rejected trying to access GitHub over HTTPS behind firewall - Stack Overflow

2014年10月26日 星期日

2014年10月13日 星期一

git show remote repo

$ git remote show
origin
test

$ git config --get remote.origin.url
$ git config --get remote.test.url

2014年9月13日 星期六

git list remote branches

可以列出本地與遠端的 branch 對應
$ git branch -avv 

2014年9月5日 星期五

git pull remote branch

$ git checkout -b < new_branch > origin/< new_branch >
fatal: git checkout: updating paths is incompatible with switching branches/forcing
Did you intend to checkout ‘origin/‘ which can not be resolved as commit?’

$ git pull




References :
Wetware » Pull A Git Branch from Remote 

2014年7月8日 星期二

使用 git 產生diff 與接受 patch

產生差異檔
$ git diff  > patch
$ git diff  --cached > patch
$ git diff  branchname --cached > patch

套用補丁
$ git apply --check patch
$ git apply patch


延伸閱讀:git format-patch

2014年7月7日 星期一

git add empty directory

$ mkdir aaa
$ cd aaa
$ vi .gitignore
# Ignore everything in this directory
*
# Except this file
!.gitignore




References :
How do I add an empty directory to a Git repository? - Stack Overflow

2014年3月25日 星期二

Deploy a project using Git push

Server :
$ git init
$ git config receive.denyCurrentBranch ignore
$ mv post-update .git/hooks


Client :
$ git remote add prod ssh://git@deploy-server:22/var/www/myproject




References :
php - Deploy a project using Git push - Stack Overflow

2013年6月18日 星期二

remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.

在套件庫端設定

$ git config receive.denyCurrentBranch ignore
  
or
 
$ git config --global receive.denyCurrentBranch ignore

2013年5月15日 星期三

git clone / fetch branch

Clone :
$ git clone ssh://yanxen.no-ip.org/my_project.git --branch branch_name
 
Fetch :
$ cd my_project

$ git pull origin branch_name




Reference :
Pull A Git Branch from Remote