Git – Change Remote URL

When managing a Git repository, there are several scenarios where updating the remote URL becomes necessary:

  • Repository Migration: When moving the repository to a different location or hosting service, the remote URL needs updating.
  • Switching Protocols: Developers may switch from HTTPS to SSH for security or convenience.
  • Ownership Changes: If the username or ownership of the repository changes, the URL must be updated.

To update the remote URL in Git, you can use the git remote set-url command. (more…)

Git Bash: Increase Terminal Scrollback Buffer Size

If you run a command that produces a lot of output in a Git Bash and you try to scroll up to the beginning of that output, you may see that it has been truncated.

The number of lines that can be displayed in the Git Bash is controlled by a scrollback buffer size (10000 lines, by default).

This short note shows how to increase the terminal scrollback buffer size in the Git Bash. (more…)

Git: Migrate Repository

If you want to move from one Git server to another, you will need to migrate your Git repositories.

This note shows how to migrate a Git repository with all its history, branches and tags from one Git server to another.

This method is simple, straightforward and can be used to move your Git repository to GitHub, GitLab, Bitbucket or any other Git server. (more…)

Git: Create Empty Branch

By default, the commands git branch <newBranchName> and git checkout -b <newBranchName> create a new branch from the current one.

This means that the new branch will be based on your currently checked out (HEAD) branch, i.e. will contain all the files and commits from the parent branch.

Let’s assume that you want to create a new empty branch without any inherited files or commits.

This short note shows how to do this. (more…)

Git Bash: Clear History

The history -cw command is used to clear a Bash history on Linux, but for some reason it doesn’t work for a Git Bash on Windows.

If you try to clear the commands history in the Git Bash using this command, it won’t work – you will still see the history of the executed commands after the application restart.

To completely erase the Git Bash history you need to locate and delete the .bash_history file and then run the history -c command. (more…)

Git: Show Remote URL & Check Origin

Remotes in Git are simply aliases that store the URLs of repositories.

By convention, an origin is the alias of the default remote repository where you publish your commits.

In Git you can work with several remotes with different aliases.

From this note you will find out how to show the configured remote URLs of a local Git repository, including the origin URL. (more…)

Create GitLab Project/Repository from Command Line

In GitLab you can create a new project/repository not only through a user interface, but also from the command line.

When you create a new local Git repository and then push it to GitLab, if this repository doesn’t exit there, the corresponding project for it will be created automatically.

This short note shows how to create a new project/repository on GitLab from the command line. (more…)

GitLab CI/CD: Trigger Pipeline Manually & API

By default, GitLab CI/CD pipelines are executed automatically on pushing new commits to a repository and don’t require any intervention once created.

However, there are also times when you need to trigger pipelines manually, without updating the project.

In this note i will show how to trigger the GitLab CI/CD pipelines manually through the GitLab’s user interface and through the API using cURL, Webhook or from another project’s .gitlab-ci.yml. (more…)