所以。我向 git 存储库添加了一些我已经几个月没有接触过的新文件。出于某种原因,在合并、拉取并将我的更改推送到 github 之后,我注意到所有新文件都像这样插入了文本:
>>>>>>>>
HEAD
c0d3234k2jl423;lk4j232;l34jk32;l23j4
Run Code Online (Sandbox Code Playgroud)
在新添加的文件中,这些类型的行是随机插入的,但可能不是完全随机的。幸运的是,没有太多新文件,我能够通过,相当容易地清理它们,然后重新添加/提交/推送,现在我相信问题已经解决了。
但是发生了什么?我对 git 和 github 还是很陌生。我怎样才能避免将来发生这种情况?我在 Windows XP 上使用 git bash 控制台。
另外 - 因为这可能是相关的 - 当我早些时候尝试通过我的 PHPStorm CLI 界面提交文件时,我会点击“提交”并且提交永远不会完成。只是不断地尝试和尝试。所以我一直不得不中止该命令,然后进入并手动删除 index.lock 文件以及 COMMIT_EDITMSG.swp 文件。
另外,这最后一次(当插入废话时),我收到一条错误消息,上面写着
E138: can't write viminfo file u:_viminfo!
Press enter or type command to continue
Run Code Online (Sandbox Code Playgroud)
也许这也有关系?就像我说的,这个问题现在似乎已经过去了,只是想知道出了什么问题以及将来如何避免它。
我正在处理的脚本需要从 git diff 中遍历每个文件。但是,我不知道如何处理文件名中的空格。任何有空格的文件都被分成“2 个文件”。我知道它们需要被包裹," "但我不知道如何在它进入@参数之前实现它。
当文件名中有空格时,我应该如何遍历文件
git diff --name-only $1
Run Code Online (Sandbox Code Playgroud)
?
这是一个重现错误的简单测试:
copyfiles()
{
echo "Copying added files"
for file in $@; do
new_file=$(echo ${file##*/})
directory=$(echo ${file%/*})
echo "Full Path is is $file"
echo "File is $new_file"
echo "Directory is $directory"
cp $file $COPY_TO
done
}
COPY_TO="testDir"
DIFF_FILES=$( git diff --name-only $1)
copyfiles $DIFF_FILES
Run Code Online (Sandbox Code Playgroud)
该脚本目前运行如下:
test.sh <git commit id>
Run Code Online (Sandbox Code Playgroud) 每次写的时候
git pull origin master
Run Code Online (Sandbox Code Playgroud)
或者
git push origin master
Run Code Online (Sandbox Code Playgroud)
或 Git Bash 中的任何其他内容我必须插入我的用户名和密码才能登录到 GitHub。
我希望使用我的公钥和私钥自动对 GitHub 进行身份验证。
我已经创建了密钥。它们在 ~/.ssh 下进入我的本地机器。我也将公钥附加到我的帐户中。但我总是被要求提供用户名和密码。
我还需要做什么才能直接使用密钥登录?非常感谢!
我正在使用内置的git prompt shell 脚本来改进我的 Bash 提示符。
. ~/git-completion.bash
. ~/git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWUPSTREAM="auto"
export GIT_PS1_SHOWCOLORHINTS=1
Run Code Online (Sandbox Code Playgroud)
我有这个庞大的企业应用程序存储库(成百上千个文件,一个非常深的目录树,.git目录几乎有 2 GB)。提示需要很长时间才能完成。
有没有办法告诉git-prompt.sh忽略这个工作区?无论是通过标志还是在我的.bashrc?
我想在我的专用服务器上创建公共 git 存储库供任何人克隆,但它一直要求我输入 git 用户的密码。
我创建了没有密码的名为 git 的用户。用过的:
密码 -d git
不幸的是,每次我尝试这样做时:
git 克隆 git@myhost:myrepo.git
我被要求输入密码。
我试过设置 sshd_config
Match user git
PermitEmptyPasswords yes
PasswordAuthentication yes
Run Code Online (Sandbox Code Playgroud)
使用 yes 和 no forPasswordAuthentication但仍然没有用。
是否有一段代码可以在 Windows 上使用 git bash 解压缩文件?我尝试用这行代码解压:
unzip somefile.zip
Run Code Online (Sandbox Code Playgroud)
它返回一个
bash: unzip: command not found
Run Code Online (Sandbox Code Playgroud) 在 Windows bash 中,它似乎git config --list显示了多个范围的设置,但没有告诉您每个范围的设置。
我试图通过将core.autocrlf所有内容设置为 false 来确保我再也不会遇到 CRLF 问题。
git config --list 给我这样的东西:
$ git config --list
core.symlinks=false
core.autocrlf=input // <-- HERE
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
diff.astextplain.textconv=astextplain
rebase.autosquash=true
credential.helper=manager
gui.recentrepo=C:/Users/Buttle/PhpstormProjects/stuffs
gui.recentrepo=C:/Users/Buttle/PhpstormProjects/lolcatz
user.name=buttletime
user.email=Buttle@example.com
core.autocrlf=false // <-- AND HERE
credential.helper=cache --timeout=3600
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly
remote.origin.url=https://github.com/buttletime/lolcatz.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
gui.wmstate=normal
gui.geometry=1385x655+182+182 420 192
branch.master.remote=origin
branch.master.merge=refs/heads/master
Run Code Online (Sandbox Code Playgroud)
似乎第二个可能是我的lolcatz项目的本地项目。但是当我检查它时,我的全局设置也是“假”。
不确定它是否是问这个问题的正确地方,我无法理解某些东西,谷歌搜索也没有帮助。
我一直在参考git教程,(显然意味着我是新手)。
我学会了git remote -v检查远程状态的命令。好了,所有的git的教程民政事务快照像这样,显示结果:
origin https://github.com/something/something-else.git (fetch)
origin https://github.com/something/something-else.git (push)
Run Code Online (Sandbox Code Playgroud)
但是,当我试图命令我得到类似的结果为origin,以及github。像这样的东西:
github https://github.com/srujan7/something-something-url.git (fetch)
github https://github.com/srujan7/something-something-url.git (push)
origin https://github.com/srujan7/something-something-url.git (fetch)
origin https://github.com/srujan7/something-something-url.git (push)
Run Code Online (Sandbox Code Playgroud)
问题:
我不确定 thisgithub和originhere 是什么意思。为什么我收到了两次?(与教程不同)我也不确定是否做错了什么,或者完全正确。将我指向其他一些解释这一点的教程也可以。
随时提出修改建议。
我想使用 TeamCity 从远程 Git 存储库中提取代码,更新文件(并暂存并提交到本地存储库),然后将提交的文件推送回远程存储库。
拉取和更新很好。如果我打开 git-bash,git push origin master然后提交(由提交到本地存储库的更新文件引起)被推送到远程存储库。美好的。
如果我尝试使用 Team City 的命令行运行程序执行此操作(针对同一个远程目标存储库),则会失败
[14:49:18][Step 3/7] Host key verification failed.
[14:49:18][Step 3/7] fatal: Could not read from remote repository.
Run Code Online (Sandbox Code Playgroud)
目标存储库使用 Gerrit 进行身份验证。我已将公钥上传到 Gerrit 并确认来自 Gerrit 的服务器主机密钥在C:\Users\AccountName\.ssh\known_hosts. 该文件夹还包含公钥和私钥。
我可以使用 git-bash 推送的事实告诉我,这些键在正确的位置,但我很困惑为什么 Team City Command Line runner 没有使用它们。
对于 ref,构建步骤的命令参数是-c "git push origin master".
谁能看到我错过了什么?
谢谢
我尝试构建gitql。
我已经安装了 go、CMake 和 MinGW,并试图让它们在 git bash 下工作,但是当我在 gitql 目录中调用 cmake 时,出现此错误:
-- Building for: NMake Makefiles
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:14 (PROJECT):
The CMAKE_C_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. …Run Code Online (Sandbox Code Playgroud)