我试图在Git中将DiffMerge配置为我的difftool,但没有运气.这是我的.gitconfig文件的一个重要部分(未显示的其他设置仅适用于用户).
[diff]
tool = diffmerge
[difftool "diffmerge"]
cmd = \"C:\\Program Files\\SourceGear\\Common\\DiffMerge\\sgdm.exe\" \"$LOCAL\" \"$REMOTE\"
Run Code Online (Sandbox Code Playgroud)
每当我git difftool从powershell命令行调用时,冲突都会直接显示在powershell界面的下方,而不是按预期在diffmerge中显示.我知道git会选择设置,因为当我检查全局配置时,我会从配置文件中获取设置:
git config --global --get-all difftool.diffmerge.cmd
"C:\Program Files\SourceGear\Common\DiffMerge\sgdm.exe" "$LOCAL" "$REMOTE"
Run Code Online (Sandbox Code Playgroud)
我正在运行powershell而不是git bash.这是因为我为windows安装了github,它提供了powershell作为git的shell,所以我不需要安装bash(还).Git版本是1.7.11.msysgit.0.
我正在尝试设置别名,因为我有很多。
出于某种原因,这是行不通的。任何的想法?
[alias]
t = "!git log --decorate --oneline | egrep '^[0-9a-f]+ \(tag: ' | sed -r 's/^.+tag: ([^ ]+)[,\)].+$/\1/g'"
Run Code Online (Sandbox Code Playgroud)
命令本身可以正常工作:
$ git log --decorate --oneline | egrep '^[0-9a-f]+ \(tag: ' | sed -r 's/^.+tag: ([^ ]+)[,\)].+$/\1/g'
1.0.0
0.9.0
...
$ git t
fatal: bad config file line 28 in /Users/alanschneider/.gitconfig
Run Code Online (Sandbox Code Playgroud) 尝试为git config设置一些别名,我知道我可以通过终端来做到这一点,但我想按此处给出的方法设置git config文件。http://gitimmersion.com/lab_11.html。但是我不完全了解我需要做什么,我已经尝试通过sublime 2将确切的文本保存到文件“ .gitconfig”中,但是它不起作用。git的主目录到底在哪里?我已经在终端中使用“哪一个git”来获取路径“ / usr / local / git / bin / git”。将文件放在/ usr / local / git / bin中没有任何作用,我尝试了其他几个目录也无济于事。
我正在尝试为我的GIT创建一个看起来像这样的别名:
[alias]
send = !git add . && git commit -m "AUTOCOMMIT: $(date)" && git push
Run Code Online (Sandbox Code Playgroud)
此别名适用于不需要任何消息的微小修改.问题是每当我运行git send它时返回以下内容:
$ git send
error: pathspec 'Fri' did not match any file(s) known to git.
error: pathspec 'Aug' did not match any file(s) known to git.
error: pathspec '22' did not match any file(s) known to git.
error: pathspec '11:31:18' did not match any file(s) known to git.
error: pathspec 'PDT' did not match any file(s) known to git.
error: pathspec …Run Code Online (Sandbox Code Playgroud) 似乎是一个简单的问题,但我找不到解决方案,在存储在缓存中的git 配置凭据(用户名和个人访问令牌)中,git config --list返回的凭据信息是这样的
credential.helper=cache
Run Code Online (Sandbox Code Playgroud)
是否可以从缓存中查看凭据,我尝试了以下三个位置
(repository_home) /.git/config- 没有关于用户名和密码的信息
~/.gitconfig - 在 repo 文件夹中找不到文件
我正在尝试设置我的 git 配置,以便我可以使用工作环境和个人环境。
这是我的文件的内容~.gitconfig(工作和私人文件恰好在 github 上):
[url "git@github.com:"]
insteadOf = https://github.com/
[core]
editor = vim
[includeIf "gitdir:~/go/src/github.com/work/"]
path = ~/.gitconfig-work
[includeIf "gitdir:~/go/src/github.com/fzd/"]
path = ~/.gitconfig-private
Run Code Online (Sandbox Code Playgroud)
以下是两个文件的内容:
[url "git@github.com:"]
insteadOf = https://github.com/
[core]
editor = vim
[includeIf "gitdir:~/go/src/github.com/work/"]
path = ~/.gitconfig-work
[includeIf "gitdir:~/go/src/github.com/fzd/"]
path = ~/.gitconfig-private
Run Code Online (Sandbox Code Playgroud)
现在让我们漫步到这些目录之一:
> cat ~/.gitconfig-work
[user]
email = workerID@company.com
name = realname
signingkey = 454684684654...
[commit]
gpgSign = true
> cat ~/.gitconfig-private
[user]
email = fzd@email.com
name = fzd
Run Code Online (Sandbox Code Playgroud)
以上都没有返回字符串。
我期待它能起作用(它会解决我麻烦的 git 配置)。
现在,“有趣”的部分:这个配置最初是我的工作配置,只有工作设置正确。当我尝试从 …
有什么区别:
$ git remote add origin git@github.com:yourname/yourproject.git
$ git config remote.origin.push refs/heads/master:refs/heads/master
$ git push
Run Code Online (Sandbox Code Playgroud)
和:
$ git remote add origin git@github.com:yourname/yourproject.git
$ git push origin master -u
Run Code Online (Sandbox Code Playgroud)
第二个版本是否比第一个版本更新更短,还是有其他差异?
从Git 1.7.0开始,您可以使用该--set-upstream选项git push.根据git push手册:
Run Code Online (Sandbox Code Playgroud)-u, --set-upstream For every branch that is up to date or successfully pushed, add upstream (tracking) reference, used by argument-less git-pull(1) and other commands. For more information, see branch.<name>.merge in git-config(1).
[user]
name = Alvin J. Alexander
email = [omitted]
[merge]
tool = vimdiff
Run Code Online (Sandbox Code Playgroud)
这是~/.gitconfig文件的样子.我以前从未遇到过这样的数据对象.这种格式是否有像json文件这样的名称?或者这是一种自定义格式?
我的目标是从此文件中提取数据以填写package.json模板.我想研究这种格式,以便更好地理解如何解析它.解析函数是否已存在?
这是一个解析它的模板:
(需要iniparser安装模块)
var iniparser = require('iniparser');
var fs = require('fs');
var home_dir = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
console.log (home_dir);
var config_file = home_dir+'/.gitconfig';
var exists = fs.existsSync(config_file);
if (exists) {
console.log("Getting some information from the git configuration...");
var config = iniparser.parseSync(config_file);
console.log(config);
return config;
}
else {
console.log("Git configuration file does not exist...");
return {};
};
Run Code Online (Sandbox Code Playgroud) 我做了很少的搜索,并发现这个别名,以保持功能分支与开发分支同步,当我手动从Git bash运行时.
sync='!f() { echo Syncing this branch with develop && git checkout develop &&
git pull && git checkout – && git rebase develop; }; f'
Run Code Online (Sandbox Code Playgroud)
我尝试将此别名放在.gitconfig中但是我收到以下错误
error: pathspec '"\342\200\223"' did not match any file(s) known to git.
Run Code Online (Sandbox Code Playgroud)
我找到的是git checkout - ,代表,回到你所在的最后一个分支创建了这个错误.
我也尝试将相同的命令放在.bashrc中,如下所示
alias sync='echo Syncing this branch with develop && git checkout develop && git pull
&& git checkout – && git rebase develop'
Run Code Online (Sandbox Code Playgroud)
这会产生同样的错误.
但是为了确保当我手动运行Git Bash中的所有命令时,它们都能正常工作,所以没有其他问题.似乎这只是因为msysgit或windows上的bash存在差异,因为我已经在Mac和Linux上阅读了这些别名对git的工作.
一些开明的头脑可以告诉我如何更改它以使其适用于Windows?
谢谢
我想列出自安装git以来用户设置的所有git配置设置.
我不知道配置设置的任何名称或值.
(在我的情况下,我想找出导致特定git行为的原因)