One particular point to note is that running the git fetch origin command will not generate an editable copy (copy) locally.
In this case, it just generates an origin/mybranch pointer that cannot be modified locally.
That's when the local It doesn't create a new branch
So how do you merge the work on origin/mybranch to the current branch?
You can run the git merge origin/mybranch command.
How to create a local branch of your own mybranch to work on, based on the remote branch
If you want to create a local branch of your own mybranch to use for work, you can build it on top of the remote tracking branch at
>git checkout -b mybranch origin/mybranch
This will give you a local branch to work on, and the starting point will be origin/mybranch
This is the general form of the command to set up tracking branches on other remote repositories.
>>git checkout -b [branch] [remotename]/[branch]
You can set the local branch to a different name than the remote branch if you want:
Now, the local branch yourbranch will automatically pull from origin/mybranch.
View all trace branches of the setup:
If you want to see all tracked branches set up, you can use the git branch command with the -vv option
The master branch is tracking the origin/master branch and is up to date
ahead 3 (ahead 3) means that there are 3 commits locally that have not yet been pushed to the server
Behind 1 (lagging behind 1) means there is a commit on the server that has not yet been merged into the local branch
The confusing point is that the values of these numbers reflect the data you grabbed from each last grab from the server, not the state when you ran the git branch -vv command. This command does not link the remote server
Pulling data from remote servers : git fetch and git pull
When the git fetch command grabs data from the server that is not locally available, it does not modify the contents of the working directory. You need to run the git merge command to merge it yourself.
git does provide a command git pull to do both of these tasks in one step.
In most cases it means that a git fetch is immediately followed by a git merge command
Deleting remote branches
git push [remotename] --delete [branch]
>> git push origin --delete mybranch
This command removes this pointer from the server. Git servers usually hold data for a while until garbage collection runs
Today covered pushing, tracking, pulling, and deleting remote branches. Next time introduce rebase
>>1、Learn a little Docker every day 5 Understanding the Docker architecture2、Talking about an alternative way to initialize a HashMap in Java3、Remembering an NginxURIrewrite optimization4、How to implement CSS layout5、Google AI Curiosity and Procrastination in Reinforcement Learning