Git rollback my commits

I commit my and push them to Git.
My colleagues commit their changes.
I commit more of my changes.

I have been told that my changes cannot be tested for
This release and have to go in the next release. I have to back out all my changes and only my changes. How can I do that?

  • git initialize remote repo
  • What is “the function name regex” for git log -L :<funcname>:<file>
  • Altering folder structure while converting svn repo to git repo using svn2git
  • Git command to open all files in a commit?
  • Git Pull Request: “Diff suppressed. Click to show.” New lines are not new
  • git-apply fails mysteriously, how do I troubleshoot/fix?
  • I use tortoise when pushing or puling my changes into Git. I am using windows XP machine.

    Yes, I pulled my colleagues work before pushing my commits.

    I have to mention though that my changes were for completely different files. None of my colleagUes touched them.

    It is just one branch, which is the integration branch.

  • Hide but still save a branch with GIT?
  • Github API - Get contents of tag instead of master
  • What is the source file which is responsible for `git reset` command?
  • Deploy yeoman angular-fullstack project to Azure
  • Git push remote rejected {change ### closed}
  • What's the difference between git-tf and git-tfs?
  • 2 Solutions collect form web for “Git rollback my commits”

    Why simply not using the git revert command ?

    Lets say initial integrated Repo is I and when your commit is Y and later your collegues commit is C. So may be the line of development looks like this. And the file system is F at present.

              (F)    
    I--Y--C1--C2
               ↑
              HEAD
    

    And as you mentioned

    I have to mention though that my changes were for completely different
    files. None of my colleagUes touched them.

    So you could keep on doing reset HEAD~1 till you reach I, the commit before you made any changes. Say there are two commits after your commit. You could use this to reach commit I.

    git reset HEAD~3
    

    And as your files are preserved this may look like

              (F)    
    I--Y--C1--C2
    ↑           
    HEAD
    

    Now you could just delete your files from the system and add the files of your collegues (to the index, its already there on FileSystem) and then do a commit. And now the dev line may look like without your changes.

        (F1) 
     I--C3
        ↑
       HEAD
    

    This is not a recommended way. The recommended way to do it is using

     git revert HEAD^
    

    Though I have never used it,so to cant tell.

    EDIT: Another way of doing it.
    Find the “SHA KEY” of the your commit “Y” and commit just before that “I”.
    It can be done using

    git log
    

    Lets say the for Y key is: 7a2ab465aad23dc66a23ade897deb65a5bf9419d
    And for I key is: 906488ac2d5a8468d725351df80e3b0f6338c9be
    Make tags for both commits like

    git tag Intercommit -a 906488ac2d5a8468d725351df80e3b0f6338c9be
    git tag YourCommit -a  7a2ab465aad23dc66a23ade897deb65a5bf9419d
    

    Checkout intercommit using

    git checkout Intercommit
    

    Then rebase the repo using

    git rebase --onto HEAD YourCommit master
    

    Now the line of dev will look like

    I--C1--C2
           ↑
          HEAD
    

    You can find more about rebasing and rewriting one commit on

    http://www.kernel.org/pub/software/scm/git/docs/v1.7.3/user-manual.html#rewriting-one-commit

    and

    http://learn.github.com/p/rebasing.html

    Git Baby is a git and github fan, let's start git clone.