只需要编辑项目根目录下的 .git/config 文件,其中 .git 为根目录下的子目录。当需要操作多个来源不同仓库的项目时,需要做这个设置,比如一个来自 github.com,一个来自私有仓库的。
% cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://github.com/eyjian/libmooon.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[user]
name = eyjian
email = eyjian@qq.com
- 附:强制用远程仓库的覆盖本地
git fetch --all&&git reset --hard origin/BRANCH
# 示例 1
git fetch --all&&git reset