Git: What does EXACTLY “git pull” do?

后端 未结 4 1391
情歌与酒
情歌与酒 2020-12-09 23:44

I know that the \"git pull\" is actually a combination of \"git fetch\" and \"git merge\" and that basically it brings the repository as it it in remote repository.

4条回答
  •  有刺的猬
    2020-12-10 00:39

    1. But still, does it mean that after "git pull" my working tree will be identical to the remote repo?

    Not necessarily. Any local commits you have on the branch you're pulling will be merged with the changes upstream. Use git pull --rebase to put your local changes on top of the upstream commits. You can get some pretty funky merge paths without --rebase.

    1. I found some cases that doing "git pull" doesn't change anything in my local repo or create any new commit?

    If there's no new commits upstream, nothing will change in your local copy either.

    1. Does it make sense that "git pull" makes changes at the index only?

    Not that I know of. Perhaps if it fails to merge with your local commits, but then you should at least get some errors along the way.

    1. If it does, how can I make the changes at index move forward to the work tree?

    git pull :) Or git rebase . This will rebase the local commits in your branch on top of the upstream commits in that branch.

提交回复
热议问题