Git环境设置及使用 - zbunix/building GitHub Wiki
- git打包方法
用git的打包命令
git archive
比如
git archive --format zip --output xxxxx.zip master
其中master是分支名称
其实,你的这个问题本身不是git的问题,应该是打包时如何忽略.git的问题。
我现在如果要将git管理的代码打包,基本上有两种办法,我将两段sh贴出来
1、这种比较土,创建了两个目录,其中一个是nogit,将.git文件删除之后,在打包
#!/bin/bash
#get real path
cd `echo ${0%/*}`
abspath=`pwd`
cd $abspath/code/git/cos
git checkout master
git pull
rm -rf $abspath/code/nogit/cos
cp -rf $abspath/code/git/cos $abspath/code/nogit
find $abspath/code/nogit/cos -type d -name '.git' -exec rm -rf {} \;
cd $abspath/code/nogit
tar zcf cos.tar.gz cos
while read LINE
do
echo "update $LINE"
cd $LINE
rsync -avu --delete --progress $abspath/code/nogit/cos.tar.gz $LINE
done < $abspath/setting.txt
rm -f $abspath/code/nogit/cos.tar.gz
2、这种是直接通过tar命令的参数来忽略.git/README等项目部署无关的文件。
#!/bin/bash
#get real path
cd `echo ${0%/*}`
abspath=`pwd`
cd $abspath/code/git/cos
git checkout master
git pull
cd ..
tar zcf ../../cos.tar.gz cos --exclude ".git" --exclude "README*"
while read LINE
do
echo "update $LINE"
cd $LINE
rsync -avu --delete --progress $abspath/cos.tar.gz $LINE
done < $abspath/setting.txt
rm -f $abspath/cos.tar.gz
- Ubuntu 10.04升级git到1.7.2或更高的可行方法
Ubuntu 10.04升级git到1.7.2或更高的可行方法 android源码编译时要求git版本不低于1.7.2, ubuntu自带的低于这个版本,
采用下面这个方式来升级git
$ sudo add-apt-repository ppa:git-core/ppa
$ sudo apt-get update
$ sudo apt-get install git-core curl
- 设置所有用户editor, Git用户名,邮件地址的缺省值
root@android-work1:/# cat /etc/profile.d/nwd.sh export EDITOR="vim" git config --global user.name $USER git config --global user.email [email protected]
- 查看当前用户git全局环境变量
os-weizb@android-work1:~$ git config -l user.name=os-weizb [email protected]
- 修改git commit后用vim编辑 git config --global core.editor vim global修改的是~/.gitconfig,对当前用户有效
- 设置 Git 的用户名及邮件地址
$ git config --global user.name [username] $ git config --global user.email [email] 没有配置用户名的时候git报错信息 [master 1861d1a] SomeDocuments Committer: Neten Your name and email address were configured automatically based on your username and hostname. Please check that they are accurate. You can suppress this message by setting them explicitly: git config --global user.name "Your Name" git config --global user.email [email protected] After doing this, you may fix the identity used for this commit with: git commit --amend --reset-author 1580 files changed, 205989 insertions(+), 0 deletions(-)
- 忽略文件或者目录权限修改
git config core.filemode false
- 查看当前用户git配置
os-weizb@android-work1:~/android/SDK2308$ git config -l user.name=os-weizb [email protected] core.filemode=false core.repositoryformatversion=0 core.filemode=false core.bare=false core.logallrefupdates=true remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* [email protected]:SDK2308.git branch.master.remote=origin branch.master.merge=refs/heads/master