Git creates branches based on historical commit

Source: Internet
Author: User
Tags sha1

Today, when using Dbus to implement RPC, it is found that the parameters passed and returned by the remote method are not correct, and the previous few days have been tested obviously normal. So it's natural to think back to the historical version and test it again, to confirm that the test environment has changed, or that the code is being modified.

But how to take out the historical version? Not very good for git, a bit of a toss to finally fix.

1. Determine the commit value of the version that needs to be removed:

#git Log
Commit 76dc4da1c919a2baf430fbe0a7362844ab274451author:zhengfeng Rao <[email protected]>date: Thu June 19 16:16:16 +0800 Improve RPC apicommit 1bfaab5c77be218618382af4a6732b3ec1196673author:zhengfeng Rao <[email Protected]>date: Wed June 20:08:31 +0800 92483401abdc41bc64bbdde1a63ed7bbee403e19Author: Zhengfeng Rao <[email protected]>date: Tue June 20:10:42 +0800 devel package can call function in Ser Vice Package by Dbus now.commit 80e79ff87718b9e56be1b4d4986d796dc046878bauthor:zhengfeng Rao <[email protected]> Date: Fri June 19:56:01 +0800 add new test files

I need the commit value of the historical version for 92483401abdc41bc64bbdde1a63ed7bbee403e19

2. Remove the version and create the branch

#git checkout-b DBUS_WORK_OK 92483401abdc41bc64bbdde1a63ed7bbee403e19

The branch "DBUS_WORK_OK" was created based on commit "92483401abdc41bc64bbdde1a63ed7bbee403e19" and the code for that version was removed.

A little note:

git checkout-b <branch name> <SHA1>


This will checkout a previous commit and open a branch point to it.

If you do not intend to make changes,
Just want to checkout out, Git checkout <SHA1> on the line, with
Detached head feature.

http://www.newsmth.net/nForum/#!article/LinuxDev/42375

More can see Git's manul:

#git Checkout--help

The sad reminder is that after the test found that the normal work of the Dbus function, incredibly wrong! Looks like it's a little busy.

-----------------------------------

Ps:

After testing, it was found that the order of the parameters in the Dbus function was modified, resulting in a parameter error passed to the remote.

3. Submit your code:

#git commit-a-M "Fix bug:params incorrect in function rpc_execute_context_query (), which'll cause dbus work abnormal"

Note: This is only submitted to branch "DBUS_WORK_OK" and is not merged on the trunk branch (because the current branch is "DBUS_WORK_OK").

4. Merge to Trunk branch "master":

Switch to Trunk branch "master":

#git Checkout Master

(The current branch is "master")

Merge:

#git Merge Dbus_work_ok

5. Delete the unwanted branch "DBUS_WORK_OK":

#git branch-d DBUS_WORK_OK

6. Continue working on the trunk branch "master".

Git creates branches based on historical commit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.