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
- Commit the edits in repository A
- Pull them to repository B
- 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.
精彩评论