开发者

Can I pull a git work-tree?

I have a repository A, and a clone of it, named B.开发者_如何学C Then, I have edited a file in the A and not commit it. My question is if I can run git pull in B to get the edition in the A?


If no "commit and push" was performed, how can a client pull get access to new revisions?

Short answer: no.


You can only pull revisions, i.e. commits. If an edit isn't committed, it isn't in the repository and can't be pulled. However, you could do something like

  1. Commit the edits in repository A
  2. Pull them to repository B
  3. In repository A, git reset --hard HEAD^ to undo the latest commit and erase the edit.

If you want to keep the edit in repository A but not the commit, omit the --hard option to reset.


If you don't want to commit the file to the master branch, commit it to another branch and pull that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜