Reputation: 28901
I have 2 development machines.
I have made uncommitted changes to the repo in machine A. These uncommitted changes includes both edits & newly created files.
I wish to move these uncommitted changes to machine B. NOTE: I do NOT want to commit these changes to the repo and pull them from machine B, becuase I don't want people to see unfinished code in BitBucket commit logs.
Note that both machine A and B has the latest version of the current repository.
According to this: Using git, how do you move some uncommitted changes from one branch to another branch in a different folder?
I should do this in machine A
$ git diff > patch
Send the patch file to mahcine B and do this:
$ git apply /path/to/patch
This usually works. But in this case the git apply fails.
When I perform $ git apply --check
I get errors similar to the following:
error: database/migrations/example.php: No such file or directory
Why is this happening? How can I fix this?
Upvotes: 3
Views: 2040
Reputation: 72256
There is no need to push all branches to BitBucket (or whatever central repository you use). Set computer A
as remote in the repo hosted on computer B
, use git fetch A
to get the branches from A
then do whatever you want with the fetched commits.
Run once on computer B
:
git remote add A <url-of-the-repo-on-A>
Replace <url-of-the-repo-on-A>
with an URL you can use on B
to access the repo located on the A
computer.
For example, assuming on A
the repo is located in /home/user1/projects/repo
and you can access A
from B
using ssh
as user1
you can use ssh://B/home/user1/projects/repo
. (You need to configure A
and B
to use public keys for authentication to not be bugged by Git about your password on A
every time it needs to access the remote repository).
If you have a different way of communication between A
and B
(f.e. a directory shared by A
that is mounted on B
) you can use it as well (assuming the repo on B
is visible this way).
After the initial set up step, every time you want to transfer the changes from A
to B
you can create a new commit on A
(on whatever branch you want, maybe you want to create a branch special for this transfer). Then you login on B
and run (in the repo):
git fetch A
(A
is the name of the repository set by the git remote
command above).
This brings into the local repo all the commits that are new in A
and are not present in the local repo. You can, as well, fetch a single branch by putting it into the command line:
git fetch A branch1
Now, that the changes are in B
you can check the branch out and continue working on it:
git checkout branch1
Or move them on top of another branch (using rebase
) or merge them or do whatever you want.
Read more about git remote
and git fetch
.
Upvotes: 3