Hi Luke,

It can be hard to understand the different options that Git provides. It sounds 
like you are in a team which is using a set of branching and merging techniques 
that do not work together (like using Hammers and screws rather than hammers 
and nails ;-)

In a team environment which has a 'blessed' repository, it is important to not 
(never) push commits to it that are in any way unfinished (untested, certified, 
etc.) to any of the 'master' release branches, where others could/would pull 
those commits and trust them.

There should be no problems if you have designated ref space for personal 
branches (which no one should trust) on that central repo (who's release 
branches are 'blessed') or if there are ref spaces feature branches you 
collaborate with colleagues on (social rules apply when to make mistakes - you 
have to apologize to them..)

The common branching process most often referred to is 
http://nvie.com/posts/a-successful-git-branching-model/? 

The one additional option is that of providing each developer with a personal 
remote repo/server for their 'backups', (perhaps on the same server as the 
'blessed repo'), so that individuals can have a separation of concerns while 
the company and individual still has security of storage.

So:
'git reset --hard' only for the most private of mistakes. Don't use it for 
commits on any branch that has been pushed publicly (e.g. those blessed' 
branches). It leaves your local copy in an older state than the public copy! 
(so only use it if there is no public copy)

'git revert' will create an additional commit that removes the old commit's 
changes (which may need a fixup of any conlicts), i.e a reverse patch - used 
when you notice an old mistake that can be fixed by an 'undo' commit.

'git checkout' does not create a commit at all, so all history is unchanged. 
Rather it only changes the content of your working directory from its old state 
to that of the commit or file you requested.

Hope that helps

Philip

  ----- Original Message ----- 
  From: Luke P 
  To: git-users@googlegroups.com 
  Sent: Saturday, July 26, 2014 11:43 AM
  Subject: [git-users] Roll back to old commit


  Hi,

   i apologize for creating topic which is here probably 100 times already, but 
although i spent so much time on researching this i still dont understand how 
to properly roll back to old commit.

  From what i understand there are 3 options. Hard reset, revert and checkout. 
The hard reset seems put me correctly back to desired commit, but then there is 
problem pushing it, if i pull i get again the latest commit, which i dont want, 
because i rolled back to older commit. So my understanding was that when i use 
hard reset, it would change the history and everything and would be changed on 
server and not localy, but i guess it gets changed only localy ? So solution 
for that was to do "git push origin master -f"  to force the push, but although 
i can then push it this way, still other people on the project cant get the 
rolled back state. Does it mean everyone on the project has to roll back as 
well ?

  The checkout is a bit confusing to me, because from what i understand its 
more for exploring the older commit rather than using it. Not sure about revert.

  Anyway, what i basicly need is just to be able to roll back to old commit and 
make sure when i do that everyone else on the project who will pull will get 
that rolled back state of the project. Because when i do the hard reset now 
with force push, if they pull it will say already up to date and when they 
push, they push the latest state of the project, which is several commits after 
the one i want to roll back to ( basicly they put it back to the original state 
before rolling back ).

  Sorry if this topic has been here already too many times, but i just have 
realy hard time understanding this. I am quite new to the git so any 
explanation and help is greatly appreciated.

  Thanks
  Luke


  -- 
  You received this message because you are subscribed to the Google Groups 
"Git for human beings" group.
  To unsubscribe from this group and stop receiving emails from it, send an 
email to git-users+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to