开发者

Can I pull a git work-tree?

开发者 https://www.devze.com 2022-12-19 18:11 出处:网络
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 \"co

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

精彩评论

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

关注公众号