Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sync works by git in different computers

Tags:

git

I have 2 computers, one in office and one in home, we use git for version control, and I want to use it to sync my works, which usually are not even ready for a small commit, so I don't want leave a commit message in our gitlab server. The first idea come to my mind is git stash, can I git stash my current work? And push the stash to the remote server. Then pull the git stash in another computer and restore the work by git pop. Something like:

This is not exactly steps, but you can get my idea.

Step 1: In Computer-Office

git stash
git push (the stash contents)

Step 2: In Computer-Home

git pull # pull the stash contents
git stash pop # pop the difference I already git stash in the Computer-office
# some modified, new files and delete some files.
git stash
git push (the stash contents)

Step 3: In Computer-Office

git pull # pull new stash content at home
git commit # the final commit
like image 408
Liao Zhuodi Avatar asked Jun 09 '26 12:06

Liao Zhuodi


1 Answers

Stash is meant for local storage, there's no way you can push that to remote unless you use other tools (dropbox etc) to transfer the .git files.

One approach is to put ur repo in dropbox, then sync uncommitted changes using dropbox.

If not you simply have to commit and push to remote, then rebase to squash the minor commits into a single one, then force push to remote so that your commit history remains neat.

You can also do git reset --soft HEAD~to remove the last commit from history but keep the changes in your local repo, which is pretty much what you are trying to accomplish with stash.

like image 66
Roy Wang Avatar answered Jun 12 '26 10:06

Roy Wang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!