Reputation: 17711
I'm working on a software project.
I use git / github.
I'm currently the only developer.
I usually work both from home place and from work place.
Before starting any session, I do a git pull
, and when finished, a git add . -A && git commit -m "my commit message" && git push --tags origin master
(I have a gitaddcommitpush alias for this).
Yesterday, after a working session, I forgot to gitaddcommitpush, from home :-(
This was my reaction whe I did realize it :-(
Now, the question:
Which actions should I perform to be able to work today, at work (on a different section of the project than I was working yesterday from home, of course), to be able tomorrow @home to merge my changes of yesterday (from home) and today (from work) ?
Upvotes: 5
Views: 4595
Reputation: 520898
Since you have been maintaining a nice linear Git workflow, I am going to suggest that you use rebasing to keep things the way they are.
You can simply work in the office today as usual, and commit your work. When you return home to work, you can do a git pull --rebase
to bring in the changes from work. Your local branch will be behind the remote version by one or more commits. Rebasing will make your home branch appear as if you actually did the last night's work on top of today's office work. Take the following steps at home:
git commit -m 'Changes from last night which I forgot'
git pull --rebase origin master
There may be conflicts from this, but it is not too likely if you really worked on totally separate parts of the project in the office.
Here is a diagram showing what the state of your home and remote master
branch will be after you commit your work at home from last night:
remote: A --- B --- C
\
local: D
Here, commit C
is the commit you made at work today, and commit D
is the commit you will make tonight (for last night's work). Now after you do git pull --rebase origin master
the diagram will look like this:
remote: A --- B --- C
\
local: D'
When you git push
your changes in, the remote will receive a single new commit on top of what it had from work. And when you go to work tomorrow, things will continue as they have been.
Upvotes: 4