关于Git的非常基本的初学者问题,来自一个命令行经验非常少的人.
git init命令开始在文件夹中工作.打开Git Bash时,我显示了我的用户名和计算机名称(在表单中username@computername)并给出了$提示.在Windows的cmd.exe中,我可以使用命令dir来列出文件夹中的所有内容,并cd更改为特定文件夹,但除非我遗漏了某些内容,否则Git Bash无法使用这些命令.
问题:指南说'如果你开始跟踪Git中的现有项目,你需要转到项目的目录并输入$ git init'.如何列出并导航到我可能想git init在Git Bash中使用该命令的文件夹?
...
...
......按照以下答案......
其他人的资源:自从得到以下答案(这有助于澄清我的初学者对Bash脚本语言和Git Bash的混淆),我发现以下资源可能对其他努力开始的人有用...
dir !)试图执行java.exe并获得可爱的错误
>> sh.exe": java.exe: command not found
Run Code Online (Sandbox Code Playgroud)
该命令在普通的命令shell中工作.
我已经检查了两者的路径,它们几乎相同,bash有一些预期的额外目录.我曾经env |grep PATH和set PATH分别检查...
where java.exe
C:\Windows\System32\java.exe
set PATH
Path=C:\Ruby193\bin;C:\Windows\system32;C:\Windows;
env |grep PATH
HOMEPATH=\
PATH=/c/Users/hooksc/bin:.:/usr/local/bin:/mingw/bin:/bin:/c/Ruby193/bin:/c/Windows/system32:/c/Windows:
Run Code Online (Sandbox Code Playgroud)
我想我错过了一些微妙的东西,任何人都有什么想法?
我有一个简短的路径片段,使它更容易阅读...但是,至少有一个java.exe的源文件夹在路径中.
我目前正在使用Git Bash导航文件目录和编辑文件。我想知道是否有命令在当前目录及其中的所有目录中搜索文件名。
要在Windows上使用git bash在git上提交一些东西我需要做,例如:
1.git add *
2.git commit -m "Commit test"
3.git push origin master
Run Code Online (Sandbox Code Playgroud)
通过这种方式,我提交了所有更改.我想只添加特定文件(*.h和*.cpp).解决方案是使用:
ad. 1.:
git add *.h
git add *.cpp
Run Code Online (Sandbox Code Playgroud)
但是这样我只在当前文件夹中添加*.h和*.cpp.问题是如何在一个命令中的当前文件夹和子文件夹中添加文件*.h和*.cpp?就像是:
1.git add *.h and *.cpp and_in_subfolders
and then:
2.git commit -m "Commit test"
3.git push origin master
Run Code Online (Sandbox Code Playgroud)
谢谢.
在我执行 git commit 后,它会提示我进行评论,以便我可以推送到 bitbucket,通常我按 alt+x,然后退出,然后 git push。但出于某种原因,它并没有让我退出。
committed new changes to bitbucket
Please enter the commit message for your changes. Lines starting
with '#' will be ignored, and an empty message aborts the commit.
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
new file: blocks/folder-navigation.block
new file: blocks/index-album.block
Run Code Online (Sandbox Code Playgroud)
....
我正在阅读这篇文章,在大多数情况下,我明白了。我想我了解变基(它获得更线性的 git 日志历史记录,而无需进行仅三向提交的提交)我也认为我了解 git 图表。但是段落中有几句话我不明白。
您会注意到该合并中的短语“快进”。因为您合并的分支所指向的提交直接 位于您所在的提交的上游,所以 Git 只是将指针向前移动。换句话说,当您尝试将一个提交与可以通过跟踪第一个提交的历史记录来访问的提交合并时,Git 通过向前移动指针来简化事情,因为没有不同的工作可以合并在一起 – 这称为“快进。”
您的更改现在位于 master 分支指向的提交的快照中,您可以部署修复程序。
我不明白的是上游,指针和最后一句话的术语。
图中的红色主框为什么是hotfix上面的?
请有这种经验的我描述一下如何正确设置CMDER的选项以在当前文件夹中使用Git Bash打开新控制台(例如在此处打开CMDER)。此字符串不起作用:
"C:\Program Files (x86)\Git\bin\sh.exe" --login -i -new_console:%__CD__%
Run Code Online (Sandbox Code Playgroud)
我试过混合这个
""C:\Program Files (x86)\Git\bin\sh.exe" --login -i"
Run Code Online (Sandbox Code Playgroud)
和这个
cmd /k "%ConEmuDir%\..\init.bat" -new_console:%__CD__%
Run Code Online (Sandbox Code Playgroud) 我已经为 Windows 安装了 Git,并且总体上对它提供的 Bash shell 中的功能集感到满意。我在使用别名时遇到了问题,该别名在我尝试过的其他任何地方都可以正常工作。
别名:
alias gl='git log --graph --format='\''%Cred%h%Creset %s %C(yellow)%an | %C(cyan)%ad%Creset %C(green bold)%d%Creset'\''' | less
Run Code Online (Sandbox Code Playgroud)
在 MacOS bash 终端 Cygwin 中,当然在 Linux shell 中,别名会产生很好的结果。
在 GFW 的 Bash shell 中,输出非常混乱:
如果我直接运行命令,没有别名,它可以正常工作。所以我知道并不是 GFW 的 Bash shell 不知道如何解析我写的命令。
我的问题:如何让这个别名在 Git For Windows 下正常工作?
我愿意使用别名的替代方法。如果 linux 函数或真正的 Git 别名会更好地工作,我对这些替代方案感到满意。不过,弄清楚为什么会发生这种情况会很好。
更新/发现 问题似乎根本不在于解释别名。如果我将管道移至“少”,则输出显示正确。因此,看起来 Git Bash Shell 中实现的“less”命令对转义序列的解释(从字面上看,我猜)与其他实现不同。因此,再多的函数调用都无法解决核心问题。
我正在编写应该使用 json 发送请求的批处理脚本。
call curl -X POST -H 'Content-type: application/json' --data '{"text": "Pull requests:\n%linksText% has been deployed to %stagingServerUrl%", "username": "Staging Server"}' http://requestb.in/ovehwtov
Run Code Online (Sandbox Code Playgroud)
我从 git bash 运行我的脚本,虽然它发送了请求,但正文格式不正确,就在它发送请求之前,我在控制台中看到错误:
curl: (6) Couldn't resolve host 'application'
curl: (6) Couldn't resolve host '"Pull'
curl: (6) Couldn't resolve host 'requests:\nhttp'
curl: (6) Couldn't resolve host 'has'
curl: (6) Couldn't resolve host 'been'
curl: (6) Couldn't resolve host 'deployed'
curl: (6) Couldn't resolve host 'to'
curl: (6) Couldn't resolve host 'unicorns2url",'
curl: (6) Couldn't resolve host …Run Code Online (Sandbox Code Playgroud) 我已经安装了Anaconda,并将Path环境变量设置为C:\Anaconda3; C:\Anaconda3\Scripts。
然后我尝试在Git Bash中运行
conda install python
但是有一条错误消息“ bash:conda:命令未找到”。我想知道为什么。
git-bash ×10
git ×6
alias ×1
anaconda ×1
bash ×1
batch-file ×1
cmd ×1
cmder ×1
commit ×1
curl ×1
git-add ×1
git-branch ×1
git-commit ×1
less-unix ×1
mingw-w64 ×1