- 1234ru / git-bash-win.md
- Git bash windows copy
- Ответы (29)
- How to copy and paste from git bash #41
- Comments
- maurolepore commented Nov 16, 2017 •
- If running from a git-bash terminal
- If running from cmd.exe (start > run > cmd.exe)
- amrrox commented Dec 21, 2018
- spencerrichardhenry commented Feb 14, 2019
- maurolepore commented Feb 14, 2019
- antoinelmtre commented Jan 9, 2020
- On Git Bash terminal
- nitink66 commented Mar 3, 2020
- AnnanFay commented Mar 23, 2020
- Johnrobmiller commented Feb 21, 2021 •
- Asparagus-inator commented Mar 5, 2021
- Can Git Bash Shell using the default windows shortcuts for Copy & Paste?
- 4 Answers 4
- Not the answer you’re looking for? Browse other questions tagged git git-bash or ask your own question.
- Related
- Hot Network Questions
- Subscribe to RSS
- How do you copy and paste into Git Bash
- 31 Answers 31
1234ru / git-bash-win.md
Далее будет рассмотрена работа с portable-версией.
В пакете присутствует не только сам git, но и средства для работы в командной строке, которые позволяют сделать рабочий процесс практически полностью идентичным таковому в Unix-системах. (При этом, в отличие от подсистемы Windows for Linux, нет ни необходимости устанавливать дополнительные компоненты ОС, ни жёстких требований к новизне версии Windows).
В первую очередь, это оболочка bash , которая поддерживает цвета и комбинации клавиш, а также сопутствующие программы из числа наиболее часто используемых в Linux ( ls , grep , curl , vim , ssh (!) и пр.) делают возможными многие привычные операции.
Для настройки bash (например, вида системного приглашения) используется стандартный файл .bashrc , который нужно разместить в домашнем каталоге пользователя ( C:/Users/пользователь ).
В первую очередь, необходимо указать работу в кодировке UTF-8:
(Кодировку также нужно будет указать самому терминалу — см. ниже).
Также наверняка захочется настроить вид системного приглашения (текущее можно посмотреть, дав команду echo $PS1 ):
Перечитать конфигурационный файл без перезапуска терминала можно командой .
Пути файловой системы
Все пути начинаются с / (как в Unix-системах). Путь вида C:/somedir отображается в виде /c/somdeir . Можно использовать и в оригинале ( C:/. ), но с ним не будет работать достройка путей по Tab .
, указывающее на домашний каталог пользователя.
Имена системных переменных нужно писать, начиная с $ , а не обрамляя % : echo $PATH , а не echo %PATH .
При прямом запуске из командной строки bash стартует в стандартной консоли Windows cmd , которая работает в кодировке CP866 . Чтобы консоль работала в UTF-8, перед запуском bash нужно дать команду CHCP 65001 .
Автоматизировать этот процесс можно так:
- Создать рядом с bash.exe файл b.bat (короткое имя — для быстрого запуска):
- Запускать bat-файл из диалога Run: Win+R; b; Enter .
В результате будет получен полностью готовый к работе терминал с командной оболочкой bash.
Редактор vi (а точнее, vim ) используется как стандартный редактор при написании commit-сообщений git . Для корректной работы с кириллическим текстом в настройках запуска vim нужно явно указать кодировку UTF-8. Это делается в файле .vimrc , который нужно поместить в домашний каталог пользователя (по аналогии с *nix-системами):
Предварительно терминалу Windows обязательно должна быть установлена кодовая страница 65001 (см. предыдущий пункт), иначе редактор будет работать некорректно.
Глобальные настройки на уровне пользователя ОС git хранит в файле .gitconfig в домашнем каталоге пользователя так же, как в Linux. Можно сразу скопировать этот файл с какого-нибудь рабочего сервера и исправить в нем нужные места, вместо того, чтобы давать набор команд git config —global .
Как правило, необходимо указать имя и email:
Без этого git не даст отправлять изменения в удаленные репозитории ( git push ).
Чтобы получать и отправлять изменения в удалённые репозитории без ввода пароля, git должен иметь возможность пользоваться ssh-ключом. У самого git нет настроек, позволяющих явно указывать ключ — в этом он всецело полагается на команду ssh .
Самый простой путь задействовать свой приватный ключ — скопировать его openssh-версию в файл
/.ssh/id_rsa (снова точно так же, как в Linux). Он будет использоваться не только при работе git, но и при использовании команды ssh для соединения к удаленным сервером напрямую (которую можно использовать как альтернативу putty).
Такой подход предполагает, что для всех соединений будет использоваться один и тот же ключ.
Если для разных хостов нужны разные ключи, потребуется более детальная настройка ssh . Подробнее см. https://stackoverflow.com/a/25924462.
Странности (то, что работает не так, как в Linux)
Git bash windows copy
268823 просмотра
29 ответа
Я использую msysgit на Windows XP.
Пробовал Ctrl + V , правый клик, средний клик, гугл . не повезло.
Ответы (29)
1008 плюса
Кроме того, чтобы скопировать из окна, попробуйте щелкнуть значок окна консоли (topleft) и выбрать «Правка» -> «Отметить», затем перетащить поле на текст и нажать клавишу «Ввод». (Вы также можете вставить через меню значок окна, но ключ быстрее.)
ОБНОВИТЬ
Начиная с Windows 10 CTRL + C , CTRL + V и многие другие функции реализованы в conhost.exe, поэтому они должны работать с любой консольной утилитой в Windows. (Необходимо включить свойства -> вкладка «Параметры» -> режим быстрого редактирования)
Автор: Amber Размещён: 21.02.2010 12:59
137 плюса
Помимо использования команд редактирования меню, вы можете непосредственно вставить в окно мерзавца Баш с помощью комбинации клавиш, Insert .
65 плюса
На самом деле это не функция git, msys или bash; каждая консольная программа Windows застревает с использованием одного и того же громоздкого механизма копирования / вставки по историческим причинам. Включение режима QuickEdit может помочь — или вы можете установить хорошую альтернативную консоль, подобную этой , и изменить ярлык git bash, чтобы использовать его вместо этого.
Автор: hobbs Размещён: 21.02.2010 01:07
58 плюса
Копирование:
Долгосрочное решение: щелкните значок Topleft> Значения по умолчанию> Выберите «Режим QuickEdit» в разделе «Параметры редактирования»> «Хорошо».
Затем выберите текст, который вы хотите скопировать. Нажмите Enter
Краткосрочное решение: щелкните значок Topleft> Изменить> Отметить. Нажмите Enter .
Вставить:
(Если «QuickEdit Mode» включен, щелчок правой кнопкой также может работать.)
Автор: HaoQi Li Размещён: 01.05.2011 05:21
27 плюса
Используйте Shift + Insert как в linux bash
Редактировать: это работает даже в замазке.
19 плюса
То , как я это сделать, чтобы держать Alt затем нажмите Space , а затем E и в конце концов P .
В Windows Alt переходит к меню окна, Space открывает его, E выбирает « Правка» и P выполняет команду « Вставить» .
Получите их правильно подряд, и вы можете вставить фрагмент менее чем за 2 секунды.
Автор: iKlsR Размещён: 27.01.2013 10:18
9 плюса
это копирует содержимое имени файла в буфер обмена и полезно для таких вещей, как копирование вашего id_rsa.pub в веб-форму.
Автор: Tim D Размещён: 01.04.2013 09:31
8 плюса
Для пасты в Git BASH CTRL + P
5 плюса
Щелкните правой кнопкой мыши по ярлыку Git Bash и перейдите на вкладку « Параметры ». Включите режим быстрого редактирования и нажмите ОК .
Теперь вы можете использовать правый клик для вставки в Git Bash, даже пароли для удаленной отправки, чего нельзя сделать с помощью Insert .
Это также позволяет легко копировать. Просто щелкните левой кнопкой мыши и перетащите в окне консоли, чтобы выбрать любой блок текста. Теперь щелкните правой кнопкой мыши на выделении, и текстовый блок будет скопирован в ОЗУ. Это намного проще и понятнее, чем другие способы.
4 плюса
console2 ( http://sourceforge.net/projects/console/ ) — это мой переход к интерфейсу терминала.
он добавляет отличные функции, такие как копирование / вставка, изменение размера окон и вкладок. Вы также можете интегрировать столько «терминалов», сколько хотите в приложение. Я лично использую cmd (базовое приглашение Windows), mingW / msysGit, и у меня есть ярлыки для погружения непосредственно в интерпретаторы python и mysql.
аргумент «shell», который я использую для git (на машине с win7):
How to copy and paste from git bash #41
Comments
maurolepore commented Nov 16, 2017 •
If running from a git-bash terminal
- copy with Control + Insert
- paste with Shift + Insert
If running from cmd.exe (start > run > cmd.exe)
First enable QuickEdit mode (Access the menu with Alt + Space bar)
Then,
- copy with Control + C
- paste with Control + V
The text was updated successfully, but these errors were encountered:
amrrox commented Dec 21, 2018
THANK YOU SO MUCH
spencerrichardhenry commented Feb 14, 2019
Is there anyway to edit the shortcut so it can be ctrl+c and ctrl+v
maurolepore commented Feb 14, 2019
antoinelmtre commented Jan 9, 2020
On Git Bash terminal
You can also go in Option > Keys and select «Ctrl+Shift+letter shortcut».
Then you will be able to use Ctrl+Shift+c and Ctrl+Shift+v which is a bit more natural than Ctrl+Insert and Shift+Insert
nitink66 commented Mar 3, 2020
not working on windows.
Its says bash: colrm: command not found
AnnanFay commented Mar 23, 2020
How do you select text in order to copy it?
If you use the mouse to select it then it’s pretty quick to copy using the right click context menu. The only time you normally want to use a keyboard shortcut to copy text is if you aren’t using the mouse to select text so you don’t need to remove your hands from the keyboard.
Johnrobmiller commented Feb 21, 2021 •
This is just my opinion, but since Windows users use ctrl+c and ctrl+v to copy/paste, the Git Bash should have shipped with that as the default key binding for Windows users. Furthermore, they optionally let people use ctrl+shift+c/v but not ctrl+c/v, which is very questionable. I don’t mean any offense to the original developers or anything, but I’m not sure why people put up with this.
Asparagus-inator commented Mar 5, 2021
This is just my opinion, but since Windows users use ctrl+c and ctrl+v to copy/paste, the Git Bash should have shipped with that as the default key binding for Windows users. Furthermore, they optionally let people use ctrl+shift+c/v but not ctrl+c/v, which is very questionable. I don’t mean any offense to the original developers or anything, but I’m not sure why people put up with this.
I think (but I am not sure as well) the reason might be is because the Ctrl+C command is being used in a different way in the terminal? I was watching CS50 Harvard lesson in Git and Github and the instructor is discussing something about SASS. The thing about scss files is that it should be converted into css files before they can be read by the browser right? but to do the converting, you should key in sass .scss .css so it would take effect. But it would be tiresome to always to do this when you want to implement changes in the css file so he taught a command where the computer will continuously watch the following files and automatically update it. I don’t remember the command but it starts with a —watch, and when he demoed it I saw the message on the terminal say ‘click Ctrl+C if you want the action to stop’ (not exact words but pretty much what it says). Not sure about this though because I am still conflicted on the differences of using Git Bash and my default command line, and I am sure that the instructor is rather using his default terminal on Mac and not Git Bash.
Can Git Bash Shell using the default windows shortcuts for Copy & Paste?
I’d like to be able to use Ctrl-C & Ctrl-V for copy and paste into the Git Bash Shell. However, the shell has Ctrl-Insert & Shift-Insert as those actions.
I don’t see an obvious way to change these shortcut keys. Am I missing something obvious?
I am using Windows 10.
4 Answers 4
Properties -> Options -> Enable ctrl key shortcuts works for me. Otherwise, you can enable the QuickEdit mode from that same Options menu, and you should be able to use Windows commands in there.
Ctrl-C sends an interrupt signal to the current program. It is useful if you, say, accidentally write a script with an infinite loop. This is why many terminals use alternatives.
I suggest learning the alternatives and leaving Ctrl-C for interrupt.
In Git Bash (2.25) there is an option to change the shortcuts from Ctrl|Shift+Insert to Ctrl-Shift+C|V.
It’s still not what you are asking for, but it’s much closer to it, than the default shortcuts.
Options=>Keys=>Shortcuts: activate option «Ctrl+Shift+letter shortcuts»
Right click on top bar and select properties then click on options then select both edit option(quick edit mode, insert mode).Properties -> Options -> edit option.emphasized text
Not the answer you’re looking for? Browse other questions tagged git git-bash or ask your own question.
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.4.16.39093
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
How do you copy and paste into Git Bash
I’m using msysgit running on Windows XP.
Tried Ctrl + V , Right click, Middle click, google. no luck.
31 Answers 31
Also, to copy from the 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.)
UPDATE
Starting from Windows 10 the CTRL + C , CTRL + V and 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)
Aside from using the edit menu commands, you can directly paste into the git bash window using the keyboard shortcut, Insert .
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 mode can help — or you can install a nice alternative console like this one, and change your git bash shortcut to use it instead.
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
Short-term solution: Click on Topleft icon > Edit > Mark. Press Enter .
Paste:
(If the «QuickEdit Mode» is on, Right clicking might work too.)
Use Shift + Insert like in linux bash
Edit: It works even in putty.
The way I do this is to hold Alt then press Space , then E and finally P .
On Windows Alt jumps to the window menu, Space opens it, E selects Edit and P executes the Paste command.
Get these correct in succession and you can paste a snippet in under 2 seconds.
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:
Enabling Ctrl + Shift + letter shortcuts got me to a Linux-like behaviour that has lowered my blood pressure. Ctrl + Shift + C / V now works.
This is suggested by the github help page:
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.
For paste in Git BASH CTRL + P
Right click on the Git Bash shortcut and switch to the Options tab. Enable Quick Edit Mode and click OK.
Now you can use right click to paste into Git Bash, even passwords for remote push, which you can’t do with Insert.
This also enables copy easily. Just left click and drag in the console window to select any block of text. Now right click on the selection and the text block will be copied in RAM. This is way more easier and intuitive than the other ways.