Share unfinished work (broken and new files) through Git

I work from three different workstations. I would like to leave the workstation in the middle of coding sessions and resume this work later on at another workstation. Given that the code is shared using a remote git repository, I would like to use git to share this work in progress.

In practical terms, work in progress means

  • there are modified files
  • new files appear without a trace,
  • there are deleted files.

In most cases, these changes are temporary: not all changes and most unexplored files will be completed in the final commit. An example of an unused file is a test file duplicated by 20 small changes for testing purposes; I take care of all these files only when I am working on a specific problem, and I do not want to waste time restoring them when switching to another workstation.

I saw other questions and solutions that use the branch to push these changes: while I'm fine with this, there is a problem that these branches will be rewritten each time, requiring git push --force(I don't like --force) or letting them become very dirty over time.

I would like to have a simple git command or alias that allows me to keep the current state of the working directory without "too much noise" with the git history. There should be a simple companion command or git alias that allows me to download these temporary changes from other workstations.

+5
source share
4 answers

Use git stash to save the changes to the file.

git stash
git stash show -p > myPatchFile

On another computer, apply them

git apply myPatchFile
+3
source
  • git add -A . say my_current_work. --force. , , . , , / . rebase -i .

  • (git-send-email).

+1

, , , .

One option is to create a commit that will add all the necessary files, and just the cherry will select it when you need it, and delete it using the interactive redirection before moving on to the public repo.

0
source

Keep a personal branch of the function (preferably in a personal repo), do everything, do not rewrite the history, use git commit --fixup=<commit>to change unwanted changes made by the commit, and when your work of the day or function is completed, just git rebase -ithis branch to the main branch or leading branch.

0
source

All Articles