Git

How to Copy and Paste in Git Bash

Git Bash is a terminal utilized by Git users for executing commands and performing multiple tasks. It has some advanced tools for Git directories, such as displaying the checked-out branches, current head, or directory name. It offers a command line experience in a Windows environment. However, it may be difficult for beginners to use this shell and perform basic operations, such as copy and pasting.

This guide will illustrate the procedure of copying and pasting in Git Bash.

Note: In the following section, we will try to copy and paste a filename for adding it to the Git repository.

How to Copy and Paste in Git Bash Using Keyboard Shortcuts?

Follow the below-mentioned procedure for copying and pasting a text in Git Bash.

Step 1: Launch Git Bash
Open the Git command line terminal “Git Bash” on your system:

Step 2: Move to Directory
Move the required Git directory by executing the “cd” command:

$ cd "C:\Users\nazma\testing"

Step 3: Check Git Directory Status
Run the below-provided command to check the current directory status:

$ git status

The output will show all untracked files that are not added into the directory:

Step 4: Open Git Bash Settings
Now, we want to add an untracked file into the directory. To do so, firstly, we will set the key to performing the corresponding operation. For this purpose, click on the below-highlighted area in the “Git Bash”:

Step 5: Enable Shortcut keys
Next, click on the “keys” option, then mark the “Copy and Paste (Ctrl/Shift+Ins)” option from the “Keyboard features” and save the changes by clicking on the “Save” button:

Step 6: Copy and Paste in Git
Go to “Git Bash” and select the text you want to copy. In our case, we will copy the file name for adding it to the repository by pressing the “Ctrl + Ins” key to copy it on the clipboard:

Next, we will press the “Shift + Ins” key to paste the file name:

That was all about using the Keyboard shortcuts for copy pasting in Git bash.

How to Copy and Paste in Git Bash Using Context Menu Options?

We can copy and paste in Git using the “Copy” and “Paste” options of the context menu. To understand this concept, try out the below-given instructions.

Step 1: Select and Copy Text
Select the required text using a mouse and right-click on it. After that, press the “Copy” option from the opened context menu. As a result, the selected text will be copied to the clipboard:

Step 2: Paste Text
Right-click and select the “Paste” option from the appeared menu to paste the copied text:

As you can see, we have successfully pasted the copied text in the terminal:

That’s all! We have discussed the easiest methods to copy and paste in Git.

Conclusion

To copy and paste in Git Bash, users need to enable the shortcut keys. For this purpose, go to its options tab, select the “keys” option and mark the “Copy and Paste (Ctrl/Shift+Ins)” option. After that, copy any text by pressing the “Ctrl + Ins” keys and paste the text with the “Shift + Ins” keys. Another method is to right-click on Git Bash and choose the “Copy” option to copy and the “Paste” option for pasting the text. In this guide, we have demonstrated the procedure of copying and pasting in Git Bash.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.