投资菜地

屋后的一亩三分绿色菜园地

2020-04-20

GIT知识汇总

git server

在 linux server上执行以下代码: apt install git apt install openssh-server

groupadd git useradd -m -g git -s /bin/bash git

su git passwd echo ssh-rsa » .ssh/authorized_keys

mkdir byeap/project.git -p cd byeap/project.git git init –bare -b master

git client

在客户端执行以下代码: git clone user@git-server:/path/project/test.git

git jobs

git.exe init

git.exe fetch –tags –force –progress – git@localhost:byeap/middle-office.git +refs/heads/:refs/remotes/origin/

git.exe config remote.origin.url git@localhost:byeap/middle-office.git

git.exe config –add remote.origin.fetch +refs/heads/:refs/remotes/origin/ git.exe config core.sparsecheckout git.exe rev-parse “refs/remotes/origin/master^{commit}” | git.exe checkout -f

git 原理

默认情况下,当您将文件添加到存储库时,Git将尝试遵循其文件系统属性并相应地设置正确的文件模式.您可以通过将core.fileMode选项设置为false来禁用此功能:

git config core.fileMode false

如果您遇到问题,Git文件模式未设置但文件具有正确的文件系统标志,请尝试删除模式并再次设置:

git update-index --chmod=-x path/to/file
git update-index --chmod=+x path/to/file

从Git 2.9开始,您可以使用单个命令暂存文件并设置标志:

git add --chmod=+x path/to/file
find ./  | grep -E 'install.sh' | xargs -t -I{} git update-index --chmod=+x {}
git filter-branch --force --env-filter '
if [ "$GIT_COMMITTER_NAME" = "zhumw" ];
then
    GIT_COMMITTER_NAME="zhumw";
    GIT_COMMITTER_EMAIL="zhumw@mti-sh.cn";
    GIT_AUTHOR_NAME="zhumw";
    GIT_AUTHOR_EMAIL="zhumw@mti-sh.cn";
fi
if [ "$GIT_COMMITTER_NAME" = "gaojin" ];
then
    GIT_COMMITTER_NAME="gaojin";
    GIT_COMMITTER_EMAIL="gaojin@mti-sh.cn";
    GIT_AUTHOR_NAME="gaojin";
    GIT_AUTHOR_EMAIL="gaojin@mti-sh.cn";
fi
if [ "$GIT_COMMITTER_NAME" = "haorengao" ];
then
    GIT_COMMITTER_NAME="haorg";
    GIT_COMMITTER_EMAIL="haorg@mti-sh.cn";
    GIT_AUTHOR_NAME="haorg";
    GIT_AUTHOR_EMAIL="haorg@mti-sh.cn";
fi
if [ "$GIT_COMMITTER_NAME" = "yushouling" ];
then
    GIT_COMMITTER_NAME="yusl";
    GIT_COMMITTER_EMAIL="yusl@mti-sh.cn";
    GIT_AUTHOR_NAME="yusl";
    GIT_AUTHOR_EMAIL="yusl@mti-sh.cn";
fi' -- --all

git push --force --tags origin 'refs/heads/*'


开源项目(更多)