WELCOME TO EHOST.COM.NP

Monday, June 20, 2016

Dealing With “Detached HEAD” State in Git

ads space

When you pull in branches from your repository remote or upstream by running say git pull origin master (to pull changes from origin master branch) or git pull upstream non-breaking-space to pull in non-breaking-space branch from upstream; checking out any of these remote branch (e.g. git checkout upstream/non-breaking-space) will result in detached HEAD state because they aren’t proper branches as they do not (currently) exist locally.

In a nutshell, detached HEAD state occurs when you try to checkout something that is not a local branch. It can be a commit, a tag or a remote branch.

when you make changes and commit them, these changes do not belong to any branch but that doesn’t mean the commits are deleted if you eventually switch to another branch.

As displayed in the command line interface, you have to check out a new branch to retain any changes and commits made like so:

Say you created a w3guy.md, staged and committed the change. And then switch to branch SupportElements.

To include the commit we made in detached head state above to our current branch; firstly, the SHA-1 checksum of the commit has to be known.

If you don’t know it, run git reflog show HEAD@{now} -10 to list ten revision history of HEAD.

Note: HEAD is actually a special type of reference that points to another reference. It may point to master or it may not (it will point to whichever branch is currently checked out).

With the SHA-1 checksum of the commit known, run git cherry-pick 1b990a8 to import or rebase the commit on the branch.

I wrote about cherry-pick in a previous post. You might want to check it out.

La Fin!

ADS SPACE

0 comments:

Post a Comment

Categories

Article How-to All Posts WordPress Android Web design Blogger Plugins CSS Google JQuery Plugins Programming Reviews Web Hosting Blogger Blogging Blogging Tips Tricks Web Development Facebook Git Internet Make Money Online Social Plugins Tips Tips and Tricks Tools Tutorials Windows WordPress Plugins Blogging Tips and Tricks Freebies GSM Google Analytics HTML How To's JavaScript Plugin Development S.E.O SEO SMS SmartPhone Social Media Tips amp; Tricks Top-Most Updates Webmaster Tools Whatsapp Applications Apps Blogger Basics Documentary Downloads Entertainment Gadgets Games Gmail Google AdSense Guest Post IPhone Make Money Blogging SVN Security Softwares Web Hosting Tips and Tricks Wordpress Tips Wordpress Tips and Tricks hostgator iOS Advertising Networks Advertising Technology Affiliates Antivirus Audience amp; Traffic Biography Blog post Blog post Blogger Blogger Errors Blogger Tips Blogger Tools Blogger Widget Blogosphere Bogger Widgets CSS selectors CSS symbols CSS3 Computer amp; Internet Content Writing Coupon Codes Data amp; Analytics Deleted blog Design DoubleClick for Publishers Email and newsletter marketting Email marketing Excel Tips Excel Tips and Tricks Facebook Tricks Feed Feedburner Feedburner subscribers Font Fun GitHub Giveaways Gmail primary inbox Gmail tabs Google sign-in Guides HTML amp; CSS HTML5 Infographics Inspirational Instagram Internet Marketing Internet Tips amp; Tricks Job Listings Knowledge Life Hacks Lists Make-Money Monetization amp; Conversion Monetize Navigation Online Marketing Other PHP Tutorials Passport Publishing amp; Content Quotes RSS Sidebar Smartphones Social Networking Status Tech Tech Blog Technology Telegram Themes UI / UX User Psychology amp; Research VB.Net Web Tools Web browser Widget Windows Tips Windows-10 ad viewability admin notice blogging tools bluehost cherry-pick clone cors custom scrollbar customizer dismissible notices duplicate post feed title git branch git clone gpg gpg2 hybridauth iPad icon font notice responsive wordpress theme same origin policy scrollbar signed git commit smartsvn theme customizer vcs wordpress theme wordpress themes

Blog Archive