Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 ALL


  Reset submodule to checkout state in git

Sometimes there would be a submodule or some submodules within one git repository, in some cases the submodule may be out of sync with the checkout state as some files in submodule may be changed unexpectedly. How to reset the submodule to be the same as the original checkout state?Let's take an example that we have a git repository A and there is a submodule called ruby-gems under it. Assuming the submodule at remote origin has commit a.And on our local environment, the repository A has a latest commit of the submodule which causes some diff difference.$ git diffdiff --git a/web-api/ruby-gems...

18,848 0       GIT SUBMODULE GIT RESET


  How to undo git changes?

When using git for version control, there is frequent need on undoing commits due to some unexpected changes. This post will introduce how to undo changes with git command in different cases.Undo commitA common undo case is that some commit needs to be reverted as the commit contains error. In this case, the code is already committed. The command to revert the commit isgit revert HEADThis command will add new a commit to the existing head to undo the previous commit. It will not change the previous commit history, hence there is no risk of losing changes.If need to revert multiple commits, run...

3,363 0       GIT GIT RESET GIT REVERT GIT CHECKOUT


  git reset vs git revert

When maintaining code using version control systems such as git, it is unavoidable that we need to rollback some wrong commits either due to bugs or temp code revert. In this case, rookie developers would be very nervous because they may get lost on what they should do to rollback their changes without affecting others, but to veteran developers, this is their routine work and they can show you different ways of doing that.In this post, we will introduce two major ones used frequently by developers.git resetgit revertWhat are their differences and corresponding use cases? We will discuss them ...

101,326 14       GIT GIT RESET GIT REVERT


  Ways to undo wrong Git operations

While using Git to version code, programmers would inevitably perform some invalid operations which are not expected. Sometimes it's difficult to deal with this kind of awkward situations. If the programmer chooses to undo the operation, the programmer needs to bear the risk of deleting something which is not supposed to be deleted if the undo is done improperly. If the programmer leaves it as is, the file needs to be updated again manually with a new commit. In this post, we will try to provide advice on how to properly undo wrong operations performed using Git for some scenarios. G...

3,086 0       GIT RESET GIT COMMIT GIT