How to Paste in Git Bash?

Git Bash is a command-line window to manage the source code of an application. For application developers, Git Bash is an inevitable tool. While writing the code, they use commands for various actions such as pulling the latest committed code, merging the code, and pushing the code to code repositories. When it comes to the source code repository, be it Github, Gitlab, or any other source code management tool, Git Bash and commands are mandatory to control versions of source code at each code commit.

Paste in Git Bash 1

In complex development environments, Git is very useful in speeding up the process of development.

In this article, we will see:

Most used Git Commands using Git Bash

NOTE: Before applying commands using Git Bash, you should be connected to Git using your username and password Git account.

Command 1: git init {Repo Name}

Enables you to create a new repository. In the above command, Repo Name is the repository name you want to keep.

Command 2: git clone {URL}

Allows you to download repo on your local environment. URL is the path from which the repository is available.

Command 3: git commit -m {“the comment of changes you have made”}

Allows you to put your code files to the centralized source code repository and to enter notes of changes you have made in this set of files.

Command 4: git log 

Shows you the version history of commits in the current branch.

Command 5: git checkout {Branch Name}

If you want to switch from one branch to another branch, use this command. {Branch Name} is the branch you want to switch to.

Command 6: git pull {Repo Link}

Enables you to pull requests to your local repo to update your repo with the latest changes made by others.

Command 7: git push {variable} {branch}

This command is the other way to “pull command”. It pushes all your changes to the specified branch on the centralized source code repository.

Command 8: git stash {variable} {branch}

This command is to store your changes temporarily and you can move to another task, come back and apply your final commit. The command is very helpful to save uncommitted changes while switching the context.

Scenarios in which “Paste Command” is useful

All the above commands are used more than 100s times a day when a developer is continuously coding. Pasting the same commands used previously makes it easier and faster to execute them and switch to the next task. Folder paths or URLs in the command are usually long and to be typed each and every time you want to push your changes or perform any action. Pasting the authentication keys or any hash values is handy when it cannot be remembered to type. Another scenario is you want to use the same commands in sequence while coding, you just do “Paste” the command and do not keep typing the same command again and again.

Git Bash command line window provides the Paste option to deal with the above scenarios.

Somehow, doing CTRL+V – Paste doesn’t work in Git Bash

In Windows 10, Shell Command Line does not allow CTRL+V if settings are not enabled. At times, new developers struggle to figure out why the shortcut does not work with the command most common and familiar to all of us.

Enable the “Paste” action for Git Bash in Windows 10 (Shell Command Line)

  1. Open the Git Bash command window.
  2. On the window top bar, right-click to open a menu.
  3. Choose the last option, Properties.
  4. Edit Options section: tick the following checkboxes.
    • Quick Edit Mode
    • Enable Ctrl key shortcuts
    • Use Ctrl+Shift+C/V as Copy/Paste
Paste Option
  1. OK to save changes.

How to Paste in Git Bash (Windows 10)

NOTE: After enabling the key shortcuts as above, follow the steps to paste in Command-Line.

  1. Open the command line.
  2. Enter the command for the first time and copy it.
    • CTRL+C
  3. The next time you want to use the same command, use CTRL+V. 
    • You can also use the Insert key to paste.
    • You can also use the right-click→Edit→ Paste from the menu. 
  4. It works!

How to Paste in Git Bash in Linux

  1. Open the command line.
  2. Copy the command with CTRL+Insert.
  3. Paste the command text with SHIFT+Insert.
  4. It works!

The more you use it, the faster it becomes

As it is said “Practice makes a man perfect”, which applies in this use case as well. The more you practice working on git commands using the terminal, you become faster and learn shortcuts to do it faster. It’s all about learning and improving on how you produce faster and quicker outputs. Executing Git Bash commands helps you do your coding tasks faster, maintain the version history of your Git commits, revert back your changes if needed, cherry-pick your changes if you need to pull your code, and merge with another branch in case of a sudden fix required. 

All this is possible with Git with just one-liner commands. Also, pasting the same set of commands, again and again, is even better in terms of faster delivery!

You may also like:

How to Delete a Repository in GitHub