I use SVN for a while now. But I just use checkout, update and commit, since I just need a backup with history.
I am trying Git now in a new project. Here is what I did:
- Created a repository in Bitbucket.
- Git clone to my machine.
- Created a couple of files.
- Git commit -a.
- Git push.
All fine. I checked Bitbucket and the files were there. That was yesterday. Today I did:
- Added some more files.
- Git commit -a.
- Git push.
And I got an error message. I didn’t save it, but it said something about fast-forward. For some reason I couldn’t push my commit to the repository. I did several fetches, commits and pushes and got the same error when pushing. Then I did a pull, which as far as I know is a fetch followed by a merge, then a push and it worked (kinda). My repository log looks like this now:
commit ef6b0e51c8278ef15d1d84770a56929f7c30cc63
Merge: 15d482c ab3938a
Author: xxx
Date: Wed Jan 25 04:25:39 2012 -0200
Merge branch 'master' of bitbucket.org:xxx/xxx
commit 15d482c0bd2e9b894afd779520dbfdbad7f43616
Author: xxx
Date: Tue Jan 24 03:50:43 2012 -0200
xxx
commit ab3938aaacb089f1c4f3bdbb8d843a105991f776
Author: xxx
Date: Tue Jan 24 03:50:43 2012 -0200
xxx
This is strange. The first commit is right. It was done yesterday. But the second should have today’s date. But it has the exact same date as yesterday’s, up to the seconds. And there is a third commit, which is just the merging, with today’s date.
Is this the way it is supposed to be? Or did I do something wrong? Do I have to merge between a commit and a push?
I figured out what the problem was. I checked “Amend Last Commit” on the second commit. So, basically I did:
The error I got was:
I tried fetch and merge. Still couldn’t push. I had to do a pull. I got:
Then I could push.
Amending a commit that had already been pushed was the problem. That is why both commits have the same date.
Thanks all for the help.