简体   繁体   中英

Git Pulling and Fetching on a branch of a branch

Git newbie here, using Visual Studio rather than command line to issue commands. My understanding of a good branching strategy is we have a "main" in the repository. We then have a "dev" branch from main which all developers work from. To implement changes we branch from "dev" branch then check back in to "dev" when work is complete via pull requests. Once "dev" work is completed after several weeks, "dev" is merged into "main".

在此处输入图像描述

What I'm struggling to satisfy myself is that if i'm working on my local branch (from "dev"), and I fetch or pull in Visual Studio to bring it up to date with other developers changes, i expect it to pull from "dev" as that is what i branched from originally. There is nothing to show in Visual Studio Synchronisation that is what it is doing.

It just says " Pulling changes for the local branch " and this is all it shows:

在此处输入图像描述

Can anyone clarify in this scenario that it will pull/fetch from originating branch ie "dev" and not the "main"? I've looked all over but cannot find anything that convinces me, i suspect it will be clearer using some command line tool.

git pull (or the equivalent GUI command) updates the current branch to the latest version on the server. Therefore, this usually only does something when you are on develop or master, or in the rare case when multiple developers are working on a feature branch.

git fetch pulls all changes to all branches from the server, but does not update your working copy. Typically, you'll look at the history after a git fetch and manually update your working copy, either by merging develop to your working branch or (more commonly) by rebasing your working copy on the latest dev branch. In visual studio, you can do the merge by right-clicking on a branch (other than the current) and executing the "merge branch to current branch" command. To rebase your branch on another, choose "Rebase current branch on"

Here's how the menu looks like (sorry, only got a german screenshot, but you should get the point)

分支操作的上下文菜单

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM