你如何复制并粘贴到 Git Bash 中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2304372/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 07:53:43  来源:igfitidea点击:

How do you copy and paste into Git Bash

gitwindows-xpcopy-pastemsysgit

提问by Trav L

I'm using msysgitrunning on Windows XP.

我正在使用在 Windows XP 上运行的msysgit

Tried Ctrl+V, Right click, Middle click, google... no luck.

尝试过Ctrl+ V,右键单击,中键单击,谷歌......没有运气。

回答by Amber

Press Insert.

Insert

Also, to copy fromthe window, try clicking the console's window icon (topleft) and choosing Edit -> Mark, then drag a box on the text, then press Enter. (You can also paste via the window icon menu, but the key is faster.)

此外,要从窗口复制,请尝试单击控制台的窗口图标(左上角)并选择“编辑”->“标记”,然后在文本上拖动一个框,然后按 Enter。(您也可以通过窗口图标菜单粘贴,但关键是更快。)

UPDATE

更新

Starting from Windows 10 the CTRL+ C, CTRL+ Vand a lot of other feature are implemented in conhost.exe so they should work with every console utility on Windows. (You have to enable Properties -> Option tab -> Quick Edit Mode)

从 Windows 10 开始,CTRL+ CCTRL+V和许多其他功能在 conhost.exe 中实现,因此它们应该与 Windows 上的每个控制台实用程序一起使用。(您必须启用属性 -> 选项选项卡 -> 快速编辑模式)

Ref: http://blogs.windows.com/buildingapps/2014/10/07/console-improvements-in-the-windows-10-technical-preview/

参考:http: //blogs.windows.com/buildingapps/2014/10/07/console-improvements-in-the-windows-10-technical-preview/

回答by Dan Rigby

Aside from using the edit menu commands, you can directly paste into the git bash window using the keyboard shortcut, Insert.

除了使用编辑菜单命令之外,您还可以使用键盘快捷键直接粘贴到 git bash 窗口中Insert

回答by hobbs

It's not really a function of git, msys, or bash; every windows console program is stuck using the same cumbersome copy/paste mechanism for historical reasons. Turning on QuickEdit modecan help -- or you can install a nice alternative console like this one, and change your git bash shortcut to use it instead.

它实际上并不是 git、msys 或 bash 的函数;由于历史原因,每个 Windows 控制台程序都使用相同的繁琐复制/粘贴机制。打开QuickEdit 模式会有所帮助——或者您可以安装一个像这样的不错的替代控制台,并更改您的 git bash 快捷方式以使用它。

回答by HaoQi Li

Copy:

复制:

Long-term solution: Click on Topleft icon > Defaults > Select "QuickEdit Mode" under "Edit Options" > Okay

长期解决方案:点击左上角图标>默认值>在“编辑选项”下选择“快速编辑模式”>好的

Then select the text you want to copy. Press Enter

然后选择要复制的文本。按Enter

Short-term solution: Click on Topleft icon > Edit > Mark. Press Enter.

短期解决方案:单击左上角图标 > 编辑 > 标记。按Enter

Paste:

粘贴:

Press Insert

Insert

(If the "QuickEdit Mode" is on, Right clicking might work too.)

(如果“快速编辑模式”打开,右键单击也可能有效。)

回答by Anatoly Mironov

Use Shift+ Insertlike in linux bash

在 linux bash 中使用Shift+ Insertlike

Edit: It works even in putty.

编辑:它甚至可以在腻子中使用。

回答by iKlsR

The way I do this is to hold Altthen press Space, then Eand finally P.

我这样做的方法是按住Alt然后按Space,然后E最后P

On Windows Altjumps to the window menu, Spaceopens it, Eselects Editand Pexecutes the Pastecommand.

在 Windows 上Alt跳转到窗口菜单,Space打开它,E选择编辑P执行粘贴命令。

Get these correct in succession and you can paste a snippet in under 2 seconds.

连续获得这些正确的内容,您可以在 2 秒内粘贴一个片段。

回答by David Carboni

I'm back to Windows for the first time in a long time and this got me cursing like a docker. I finally found this:

我很长一段时间以来第一次回到 Windows,这让我像 docker 一样诅咒。我终于找到了这个:

ctrl_shift_letter_shortcuts

ctrl_shift_letter_shortcuts

Enabling Ctrl+Shift+lettershortcuts got me to a Linux-like behaviour that has lowered my blood pressure. Ctrl+Shift+C/Vnow works.

启用Ctrl+ Shift+letter快捷方式让我进入了一种类似于 Linux 的行为,降低了我的血压。Ctrl+ Shift+ C/V现在有效。

回答by Tim D

This is suggested by the github help page:

这是github 帮助页面建议的:

clip < filename

this copies the contents of filename to the clipboard and is useful for doing things like copying your id_rsa.pub to a web form.

这会将 filename 的内容复制到剪贴板,这对于将 id_rsa.pub 复制到 Web 表单等操作非常有用。

回答by Ehigie Paul

For paste in Git BASHCTRL+ P

用于粘贴Git BASHCTRL+P

回答by datasn.io

Right click on the Git Bash shortcut and switch to the Optionstab. Enable Quick Edit Modeand click OK.

右键单击 Git Bash 快捷方式并切换到选项选项卡。启用快速编辑模式并单击确定

Now you can use right clickto paste into Git Bash, even passwords for remote push, which you can't do with Insert.

现在,您可以使用右键单击粘贴到 Git Bash 中,甚至是远程推送的密码,而使用Insert则无法做到这一点。

enter image description here

在此处输入图片说明

This also enables copy easily. Just left clickand dragin the console window to select any block of text. Now right clickon the selection and the text block will be copied in RAM. This is way more easier and intuitive than the other ways.

这也使复制变得容易。只需在控制台窗口中左键单击拖动即可选择任何文本块。现在右键单击选择,文本块将被复制到 RAM 中。这比其他方式更容易和直观。

Image source: https://danlimerick.wordpress.com/2011/07/23/git-for-windows-tip-how-to-copy-and-paste-into-bash/

图片来源:https: //danlimerick.wordpress.com/2011/07/23/git-for-windows-tip-how-to-copy-and-paste-into-bash/