tags:

views:

148

answers:

3

I have a repository A, and a clone of it, named B. 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?

+3  A: 

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

Short answer: no.

jldupont
You don't need a push to perform a pull on B. But that doesn't change the answer.
Tomas Markauskas
@Tomas: of course, provided that the repo isn't empty ;-)
jldupont
A: 

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

Christoffer Hammarström
+1  A: 

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.

calmh