GitHub has a new service which everyone needs to know about. GitHub Gist, or simply Gist is a service which allows for easy code sharing with each other, publicly or privately. The reason I’m sharing this with all of you today is that most beginners find it difficult to elaborate their problems and instead follow bad practices. They share images of code which isn’t sufficient to debug the code or find issues because:
- the person trying to help doesn’t have access to the written code. He/She has to rewrite the code shown in image to debug which no one would do for sure.
- images mayn’t be clear
Gist has made it super-easy for all the programmers to share their code with others. You just copy-paste code from your IDE and paste in the online service and it generates a link which you can share with others. That’s it!
Now go to GitHub Gist.
Now you can see that it provides you with lots of options to customize your code look. First, you need to provide file name with extension. By extension, it determines in which language the code has been written in. For example, if you write MyFile.java, it will know that the code is in Java. Once it figures out the language, it can do proper code formatting.
You can also set how to indent code, how much to indent and if to wrap the code or not. For example, let’s put some sample code:
Now click on Create public gist if you want to remain it public otherwise click Create secret gist. So we just get the gist like this:
You can see proper Code Highlighting according to the language. The Revisions tab will show you how you edited the file throughout its history if any. For now, there’s no revision since we’ve just created it. Now just click on Embed drop-down menu as shown in the screenshot and choose an option to Share.
It will give you the sharable link which you can share with others and help others debug the code easily. To check my just created gist, click here. To read more about gists, here’s an official article.
Don’t forget to share your views about this article.