简体   繁体   English

Git获取远程分支

[英]Git fetch remote branch

A few hours ago I created a new branch on my home machine (eg. branch2), and pushed it to remote. 几个小时前,我在家用计算机上创建了一个新分支(例如branch2),并将其推送到远程。 On another machine at work, I created the same local branch, but fetching remote branch doesn't update my local repo with git fetch . 在工作的另一台计算机上,我创建了相同的本地分支,但是获取远程分支不会使用git fetch更新我的本地存储库。 My guess is that my local branch on other machine isn't tracked. 我的猜测是我的其他计算机上的本地分支未被跟踪。 Should I add track to my local branch, delete local branch, and checkout on remote branch? 我应该在本地分支中添加曲目,删除本地分支并在远程分支上签出吗?

You need to rebase your local branch with the remote branch. 您需要使用远程分支重新建立本地分支。

For this just do the following:: 为此,请执行以下操作:

git fetch
git rebase origin/your_branch

This should solve your problem. 这应该可以解决您的问题。

Git fetch only used to fetch the delta from the remote. Git提取仅用于从远程获取增量。 If you want to fetch the remote content and want them in your working directory. 如果您要获取远程内容并将其放在您的工作目录中。

git fetch

Only fetches the delta only. 仅获取增量。

If you want to fetch the remote contents and want the changes within your remote repository. 如果要获取远程内容并希望在远程存储库中进行更改。

git pull = git fetch + git merge

Try using pit pull and the results will be in your working directory. 尝试使用pit pull,结果将在您的工作目录中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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