Move Uncommited Changes In Git To A Different Computer

From Littledamien Wiki
Jump to navigation Jump to search

On the remote machine, create a branch for transferring the uncommitted changes.

$ git co -b xfer
$ git add [changes]
$ git commit -m "my message"

On the local machine, add the remote machine as a remote repo.

In the command below replace [ALIAS] with the alias for the remote repo. Replace [REMOTE_HOST_ADDR] with the address or host name of the remote computer.

$ git add remote [ALIAS] ssh://[REMOTE_HOST_ADDR]/path/to/repo

Configure both the local and remote computers to use public keys for ssh authorization to avoid entering the ssh password when running git commands.

Switch to the xfer branch on the local machine and fetch the changes from the remote machine. Replace [ALIAS] with the alias from the git add remote command.

N.B. git fetch retrieves the git metadata describing all of the changes in the repo without copying any files. git pull pulls the changed files from the remote.

$ git fetch [ALIAS]

Switch back to the main branch and merge in the changes when the larger set of edits are ready to be incorporated into the project.

$ git co master
$ git merge xfer
$ git push