DEV Community

Git Remote Guides

The git remote command lets you create, update, delete and view remote repos, such as on GitHub. Learn more below.

This is a collection of top and trending guides written by the community on subjects related to Git Remote properties. For all things git, check out the git tag! Please contribute more posts like this to help your fellow developer in need.

Git and GitHub: How to Hard Reset Local and Remote Repository

Don't do a hard reset if you've already pushed the commits in question to a shared remote repository. If another developer pulls and starts basing their work on the commits that the reset removes from the commit history, you're going to create huge problems.


Removing Accidentally Committed Files From Remote History

Seems like a rite of passage to accidentally push some api keys or node_modules or sensitive data into a public repo. Then in a panic I git rm -r the file and commit that next (...but that simply unstages it) and in a flight of terror, force push that edited and rebased history. But a look through my github commit history will show in diff, and the incriminating files remain firmly implanted in my remote repo.


Adding a New Remote and Merging Unrelated Branches

When I have to merge unrelated histories, it's usually because I need to push to a remote repo that already has some content. A good use case is when you have made a new GitHub repo with a readme, but now you need to push a totally different local repo to this GitHub repo. These repositories are not related to each other and can't be merged using the default settings.


Generate Multiple SSH Keys for Multiple Remote Accounts

If you clone from your default account just copy the output when you click Clone inside your remote repository.

If you clone from your company account, you need to alter the host with the host you specified in your config.


Git 101 — Step 1: setup, create repo local and remote repository

Your password can’t be set in the same way. When you push your changes to a remote repository, your password will be asked in the terminal.


Reset or sync local branch to a remote repository

Now you have added a remote that points to the original repo, much like how you usually interact with the fork in your Github. Time to get the latest update.


Remove files or folders from remote git

Recently when working on one of the project that had just started, I accidentally pushed IDE folder to remote repository and I was there googling again, so I thought, why not write blog for this?. I can always come straight to my blog if this happens again and I can also help my fellow developers this way, right?


How to sync your local git and remote git repository changes?

Today we will focus on how we can synchronize our GitHub local repository master with an upstream repository branch of the GitHub project.

Now, you might think what is an upstream branch,

Upstream branches define the branch tracked on the remote repository by your local remote branch (also called the remote-tracking branch), the below figure will help ya'll understand.


Editing Remote PHP Project Using Netbeans

Consider this scenario. You wrote some piece of code and placed it on a remote server. Now you need to edit the source file. How you will do it?


How to manage multiple remote repositories with git (terminal)

In this guide, we will go through the steps that I use when setting up and working with multiple remote repositories. In this case, we will be working with two namely origin which is our copy and upstream which is the main repo.


Git: push to a new remote branch

Usually <remote> would be origin unless working with another repository (eg. deploying app to heroku)

origin stands for the remote repository that a project was originally cloned from.


How to delete remote commits in git?

Assume you have pushed commits in order A1 => B2 => C3 in remote repository.


How to restore (recreated) a deleted remote git branch

I ran into this when I was cleaning up my local git. I deleted both a local and its remote branch on origin! 🤦‍♂ And the branch I deleted is still in a Merge (Pull) Request! 💀 I used a third party app called SourceTree (I’m sure you heard of it) to delete them, so my commit is not in the reflog


Git - Checking Out Remote Branches

So, if you want to run a feature branch locally, how exactly do you pull a branch from a remote repository without merging it into an existing local branch?


Git: How to keep your fork updated with remote repository

We can list the remote repositories for our repo with git remote -v and add the original repo as follows:


Git Simplified: Working with Remote Repositories

If you do not have write access, there is yet another additional step. Go into the cloned repository and add an upstream remote (fancy name for the source repository).


Local Git Branch Prune/Delete Against Remote in Python

Automation is a programmer's best friend. Its an investment of time and skill in order to make your life and job easier. Hey, we have all been there. You are working on a project and you are attempting a major change. So you create a new branch off of the master and make your changes. Publish/Commit/Push. Now you have to look into a bug but you don't want to merge your changes in without testing yet. You create a new branch off of the master and resolve your bug there. Tested and merged into master. After weeks of doing this, you realize that your local branches have piled up and are most likely dead (assuming that you delete your branches in remote once they are merged). So you will need to run a command to prune, then run a command to get branches including remote, then run another command to delete old branches...bleh.


Menggunakan SSH untuk Remote GitHub

Halooo semuanya pada kesempatan ini, saya coba membagikan cara untuk menggunakan SSH untuk remote GitHub. Sebelum menggunakan SSH ini pasti kalian seringnya menggunakan HTTPS, nahh kekurangan dari HTTPS ini adalah kita harus menyimpan password GitHub kita kedalam config agar setiap push commit tidak perlu input email/username dan password lagi.


Git remote backups

As part of my development process, I've made a habit of keeping two remote repositories for every project I work on. One remote repository is on services such as Github, Gitlab etc. and second remote is on a separate/external hard disk.


วิธี ลิสต์ และ ลบ Git remote tag

เมื่อวานต้องจัดการเรื่อง tag ของ git remote repository ได้รู้คำสั่งที่ต้องใช้ในการลิสต์และลบ tag ที่อยู่บน remote repository เพิ่มขึ้นมา ซึ่งเราสามารถทำได้ดังนี้


Keeping your forked repo in sync with the remote repo

Checking remote versions

git remote -v


The Best JetBrains Plugins For Remote Working

What do developers want? Money, flexible schedules, pizza? Sure. Effortless remote collaboration? Hell, yes! Programming is a team sport and without proper communication, you can’t really expect spectacular results. A remote set-up can make developer-to-developer communication challenging, but equipped with the right tools you have nothing to fear. Let’s take a look at the best JetBrains plugins that can seriously improve your remote working routine.


Git Remove Local and Remote Tag : The Final Guide

In order to delete a remote Git tag, use the git push command with the -–delete option and specify the tag name.


🔧 Git remote readd alias

tl;dr Alias for removing Git remote and adding it back


Deleting remote-pruned branches in Git with PowerShell

It's easy to wind up with a substantial collection of branches that aren't on the remote anymore that keep Git's gc from cleaning up as much as it should. Let's get rid of them.


[git] change remote repository url

If remote -v shows multiple remote repositories, i.e. origin, github, gitlab.., please adjust the grep command.


Automate your git push to remote server

Note: In my example I am pushing my local dev branch to remote dev branch. You may omit passing branch name if you are working on your default branch, i.e. main or master, whatever is set in your config.


Happy Git Remote coding!