git connect remote branch

 Today, when I use git to connect to the remote dev branch, the following situation occurs

$ git checkout -b dev origin/dev
fatal: 'origin/dev' is not a commit and a branch 'dev' cannot be created from it

Then check the information and use git fetch to solve

The git fetch command is used to download objects and refs from another repository
# Fetch branches and/or tags (collectively "refs") and objects necessary to complete their history from one or more other repositories. The remote-tracking branch has been updated (commit in Git terminology), and these updates need to be fetched back locally, using the git fetch command.

There are also some other commands:

$ git push origin master // push the local master branch to the remote

same

$ git push origin dev // push the local dev branch to the remote
$ git checkout -b dev origin/dev // Create the dev branch of the remote origin to the local

At this time, the local dev branch is linked to the remote dev branch, and pushing directly on the dev branch will directly push it to the remote dev branch

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324591947&siteId=291194637