Shweta
Shweta

Reputation: 325

What does "No remote for the current branch" mean?

What does "remote" mean here? What does "No remote for the current branch" mean?

I am trying to merge my changes to my code in Git and I get this message.

Upvotes: 13

Views: 38564

Answers (3)

Ustas
Ustas

Reputation: 390

ONE:

A local branch is a branch that only you (the local user) can see. It exists only on your local machine.

while

A remote branch is a branch on a remote location (in most cases origin). You can push the newly created local branch myNewBranch to origin. Now other users can track it.

What are the differences between local branch, local tracking branch, remote branch and remote tracking branch?

TWO:

  1. You have cloned a project and, somehow, the .git directory got deleted or corrupted. This leads Git to be unaware of your local history and will, therefore, cause it to throw this error when you try to push to or pull from the remote repository.

  2. You have created a new repository, added a few commits to it, and now you are trying to pull from a remote repository that already has some commits of its own. Git will also throw the error in this case, since it has no idea how the two projects are related.

https://www.educative.io/edpresso/the-fatal-refusing-to-merge-unrelated-histories-git-error

THREE:

A remote branch is a branch on a remote location (in most cases origin ) i.e your online repository.

Upvotes: 3

VonC
VonC

Reputation: 1326994

A merge between two local branches of your local repo should not require any "remote" (which is a reference to an upstream repo URL)

But: As mentioned in git merge man page, section CONFIGURATION:

If merge is called without any commit argument, merge the upstream branches configured for the current branch by using their last observed values stored in their remote-tracking branches.

The values of the branch.<current branch>.merge that name the branches at the remote named by branch.<current branch>.remote are consulted, and then they are mapped via remote.<remote>.fetch to their corresponding remote-tracking branches, and the tips of these tracking branches are merged.

So, if you want to merge another local branch into your current checked out branch, don't just type git merge (which would trigger the fatal: No remote for the current branch. error message)

Type:

git merge anotherBranch

You will need to add a remote later if you want to push to an upstream repo.

See more with: "Definition of “downstream” and “upstream”".

Upvotes: 12

Leandy
Leandy

Reputation: 633

you should connect the remote respository from local,use the command "git remote add origin 'your remote address from github' "

Upvotes: 1

Related Questions