Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy local changes from one pc to another using git

Tags:

git

I'm using Git and sometimes i start my work on my local desktop and i want to copy these open works to my laptop to finish it at home.

To keep my repository clean, i don't want to push these changes to some branch because my work may be unfinished, untested an so on...

like image 988
Gatschet Avatar asked Aug 06 '15 11:08

Gatschet


People also ask

How do I switch between git versions?

Just type git checkout a . Or perhaps more usefully, git checkout -b mybranch a , to checkout a as a new branch mybranch . If you want to revert b and c , you can use git revert , or to remove them entirely from your current branch's history, you could git rebase -i a and throw them out.


2 Answers

This is my workflow to copy my changes from one PC to another:

Stash your changes with:

git stash save myWork

Save stash to file with:

git stash show -p  > myWork.txt

Move generated file (myWork.txt) to other PC Patch new PC with:

git apply myWork.txt

Clear all Stash:

git stash clear
like image 97
Gatschet Avatar answered Oct 12 '22 23:10

Gatschet


You're over-complicating the problem, all what you need to do is:

At work

git checkout -b temp_branch
git push origin temp_branch

At home

git fetch && git checkout temp_branch

Then delete it:

git branch -d temp_branch
git push origin :temp_branch

For extra cleaning, you can prune the deleted branch

git remote prune temp_branch

Don't be afraid of creating branches, they're very cheap.

like image 37
Maroun Avatar answered Oct 13 '22 00:10

Maroun