默认情况下git push --force

Tho*_*mas 2 git

当我这样做时git push,git会在必要时自动进行强制更新,就像我指定了该--force选项一样.我很久以前就配置了这个.我不再需要此行为,并且无法找到影响此行为的配置变量.我在.gitconfig.git/config文件中找不到任何相关内容.

编辑:添加了我当前的配置文件:

我的.gitconfig:

[user]
    name = xxxx xxxx
    email = xxxx
[core]
    excludesfile = /Users/xxxx/.gitignore_global
[difftool "sourcetree"]
    cmd = opendiff \"$LOCAL\" \"$REMOTE\"
    path = 
[mergetool "sourcetree"]
    cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
    trustExitCode = true
Run Code Online (Sandbox Code Playgroud)

本地回购配置:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
[remote "origin"]
    url = ssh://xxxx@xxxx.com/var/git/tw
    fetch = +refs/heads/*:refs/remotes/origin/*
    push = +refs/heads/*:refs/heads/*
[remote "AudioCopy"]
    url = /Users/xxxx/Src/AudioCopy/myacp
    fetch = +refs/heads/*:refs/remotes/AudioCopy/*
[submodule "Sources/iPhoneInterface/SoundCloud/CocoaSoundCloudAPI"]
    url = git://github.com/soundcloud/CocoaSoundCloudAPI.git
[submodule "Sources/iPhoneInterface/SoundCloud/CocoaSoundCloudUI"]
    url = git://github.com/soundcloud/CocoaSoundCloudUI.git
[submodule "Sources/iPhoneInterface/SoundCloud/JSONKit"]
    url = git://github.com/nxtbgthng/JSONKit.git
[submodule "Sources/iPhoneInterface/SoundCloud/OAuth2Client"]
    url = git://github.com/nxtbgthng/OAuth2Client.git
[submodule "Sources/iPhoneInterface/SoundCloud/OHAttributedLabel"]
    url = git://github.com/nxtbgthng/OHAttributedLabel.git
[branch "linux"]
    remote = origin
    merge = refs/heads/linux
Run Code Online (Sandbox Code Playgroud)

远程repo配置:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = true
Run Code Online (Sandbox Code Playgroud)

样品运行:

~/Src/tw % git push
Counting objects: 7, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 394 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
To ssh://xxxx@xxxx.com/var/git/tw
   26636fd..4247b2e  guile20 -> guile20
 + e80b72f...3578ee1 linux -> linux (forced update)
~/Src/tw %
Run Code Online (Sandbox Code Playgroud)

CB *_*ley 5

从您的[remote "origin"]配置条目看起来您已经设置了镜像推送.如果这不是你想要的,我会完全摆脱这条线.如果您对镜像样式推送感到满意但又不想强制(这对我来说没有多大意义),您希望+[remote "origin"]本地存储库配置部分的推送行中删除前缀.

或者:

git config --unset remote.origin.push
Run Code Online (Sandbox Code Playgroud)

要么:

git config remote.origin.push 'refs/heads/*:refs/heads/*'
Run Code Online (Sandbox Code Playgroud)

取决于你做出的选择.