本地git push,服务端更新
来源:互联网 发布:软件设备 编辑:程序博客网 时间:2024/06/14 01:03
原帖
push 到没用–bare 创建的仓库会被阻止
修改/.git/config
[receive] denyCurrentBranch = ignore
push 后对方被记录的文件不会自己更新,需要使用脚本
#!/bin/sh## This hook does two things:## 1. update the "info" files that allow the list of references to be# queries over dumb transports such as http## 2. if this repository looks like it is a non-bare repository, and# the checked-out branch is pushed to, then update the working copy.# This makes "push" function somewhat similarly to darcs and bzr.## To enable this hook, make this file executable by "chmod +x post-update". git-update-server-info is_bare=$(git-config --get --bool core.bare) if [ -z "$is_bare" ]then # for compatibility's sake, guess git_dir_full=$(cd $GIT_DIR; pwd) case $git_dir_full in */.git) is_bare=false;; *) is_bare=true;; esacfi update_wc() { ref=$1 echo "Push to checked out branch $ref" >&2 if [ ! -f $GIT_DIR/logs/HEAD ] then echo "E:push to non-bare repository requires a HEAD reflog" >&2 exit 1 fi if (cd $GIT_WORK_TREE; git-diff-files -q --exit-code >/dev/null) then wc_dirty=0 else echo "W:unstaged changes found in working copy" >&2 wc_dirty=1 desc="working copy" fi if git diff-index --cached HEAD@{1} >/dev/null then index_dirty=0 else echo "W:uncommitted, staged changes found" >&2 index_dirty=1 if [ -n "$desc" ] then desc="$desc and index" else desc="index" fi fi if [ "$wc_dirty" -ne 0 -o "$index_dirty" -ne 0 ] then new=$(git rev-parse HEAD) echo "W:stashing dirty $desc - see git-stash(1)" >&2 ( trap 'echo trapped $$; git symbolic-ref HEAD "'"$ref"'"' 2 3 13 15 ERR EXIT git-update-ref --no-deref HEAD HEAD@{1} cd $GIT_WORK_TREE git stash save "dirty $desc before update to $new"; git-symbolic-ref HEAD "$ref" ) fi # eye candy - show the WC updates :) echo "Updating working copy" >&2 (cd $GIT_WORK_TREE git-diff-index -R --name-status HEAD >&2 git-reset --hard HEAD)} if [ "$is_bare" = "false" ]then active_branch=`git-symbolic-ref HEAD` export GIT_DIR=$(cd $GIT_DIR; pwd) GIT_WORK_TREE=${GIT_WORK_TREE-..} for ref do if [ "$ref" = "$active_branch" ] then update_wc $ref fi donefi
下载
保存到.git/hooks/post-update
chown user:user post-updatechmod +x post-update
0 0
- 本地git push,服务端更新
- git本地仓库push
- git push拒绝更新
- GIT本地服务端搭建顺序
- 【git&github学习笔记】push本地项目
- git for c#, commit本地,push服务器
- Git push本地代码到github出错
- git 取消本地 commit (未push)
- git本地push代码报broken pipe
- git 本地项目push到GITHUB
- git 更新代码到本地
- Git把本地代码push到oschina git仓库
- git&github 使用git将本地项目push到github
- Git Push(向远程Github提交本地代码)
- git commit没有push,想要回退本地版本库
- 使用Git命令push本地项目至github服务器中
- GIT的Push和Pull,强制Pull覆盖本地命令
- git push将本地分支推送到远程
- 我的Python第二篇 条件分支和循环篇
- 10Spring标签
- 关于对象初始化内部顺序的个人见解
- 将XNA整合到WinForm
- 15Spring拦截器
- 本地git push,服务端更新
- APP开发实战82-Android动态权限申请
- linux添加开机自启动脚本示例详解
- Spring与ThreadLocal
- -[NSDecimalNumber rangeOfCharacterFromSet:]: unrecognized selector sent to instance
- Codevs 1697 ⑨要写信
- java一些经典算法题
- RabbitMQ 三种Exchange
- IntelliJ IDEA中的Maven项目下的配置文件发布问题