What is git stash & readme.md file.
In this blog, we will try to explore git commands like git stash and README.md file.
Today’s Motivation
“A pessimist sees the difficulty in every opportunity; an optimist sees the opportunity in every difficulty.”
So, Let’s get started… 🙂
What is the use of git stash command?
The git stash command temporarily shelves (or stashes) changes you’ve made to your working copy so you can work on something else, and then come back and re-apply them later on. Stashing is handy if you need to quickly switch context and work on something else, but you’re mid-way through a code change and aren’t quite ready to commit.
The git stash command takes your uncommitted changes (both staged and unstaged), saves them away for later use, and then reverts them from your working copy.
for e.g. Let’s say, you start working in the portfolio.txt and about.txt file to add some functionality that is not yet completed to commit (means to save). Then suddenly, some of your fellow team members say that we have to show the project to the client now. Now, What will you do, you have made modifications in the portfolio.txt and about.txt file. You might be thinking let’s take the backup of the edited modifications, then why we are using git? If we want to take the backup of the code. So, here comes the git stash
command to save your uncompleted work. Suppose, the modifications you made is just 10–30 lines of code which you can write again once deleted so the git command is git reset --hard
. If not, then the git stash
command comes into the picture.
Git stash save
The command is like Git stash. But this command comes with various options.
Git stash with message
In the above image, we stash both the files with a message so we can understand what changes I have done in these files.
To stash a particular file the command is :
git stash save file-name
In the beginning image, you might see the tracked files which are modified, the files are “about.txt” and “portfolio.txt”. But after stash both the files, we perform the command git status
which shows “nothing to commit, working tree clean” i.e. the modified file is not shown because it saves the file temporarily in the master branch and your modified file contents will be not displayed, the only display is your last commit contents.
Git stash list
Before discussing this command, let me tell you something about how stash works.
When you Git stash or Git stash save, Git will actually create a Git commit object with some name and then save it in your repo.
So it means you can view the list of stashes you made at any time.
git stash list
You can see the list of stash made. And the most recent stash will be at the top.
And you can see that the top stash is given a custom message that we did it earlier (using git stash save “message”
).
Git stash apply
This command takes the top-most stash in the stack and applies it to the repo means whatever, we changed in the about.txt and the portfolio.txt file will come back. In our case, it is stash@{0}.
If you want to apply some other stash you can specify the stash id.
But after applying, the stash will not be deleted automatically. So, to delete the stash we have a command called git stash pop
.
Git stash pop
This command is very similar to stash apply but it deletes the stash from the stack after it is applied.
for e.g. Let’s say, you have multiple stashes. As you can see the top stash is deleted and ‘stash@{0}’ is updated with the older stash. Likewise, if you want a particular stash to pop you can specify the stash id.
Git stash show
This command shows the summary of the stash diffs. If you want to see the full diff, you can use
git stash show -p
Likewise, with other commands, you can also specify the stash id to get the diff summary.
git stash show stash-id
Git stash clear
This command deletes all the stashes made in the repo. It may be impossible to revert.
git stash clear
Git stash drop
This command deletes the latest stash from the stack. But use it with caution, it may be difficult to revert.
git stash drop stash-id
If everything goes fine, you can commit the changes and push to the master branch.
What is the README file?
A README (as the name suggests: “read me”) file in a project (including those projects hosted on GitHub) is written by people (project developers) for the other people to read. It is, simply the “front page” of the project; the “place ” where everyone gets started.
It usually describes what kind of project it is, how it can be useful, how to install and use it — also, the list of authors, guidelines for contributing, license notice and whatever else the developers would want others, people, to read.
The Open-source community is growing rapidly. Developers release new open-source projects on GitHub every day. As a result, it’s becoming more and more difficult to get your own project to stand out from the sea of open-source software. However, you can do a few things to increase your chances of grabbing other’s developer’s attention. One effective and simple technique is putting up a nice-looking and helpful README file.
The .md
extension means markdown. README.md
is used to generate the Html
summary you see at the bottom of the projects.
Here you will write all the information that is commonly required to understand what the project is about.
Let’s try to understand Markdown syntax Cheat Sheet.
Markdown is a way to style text on the web. You control the display of the document; formatting words as bold or italic, adding images and creating lists are just a few of the things we can do with Markdown. Mostly, Markdown is just regular text with a few non-alphabetic characters thrown in, like # or *.
Headers
- To write heading we have to use # symbol, we can use 1 to 6 level heading as we do in HTML
#H1##H2###H3
Text Styling
Common text_Emphasized text_ or *Emphasized text*~~Strikethrough text~~__Strong text__ or **Strong text**___Strong emphasized text___ or ***Strong emphasized text***
Links
To add links use square brackets [] followed by a pair of parentheses (). In the square brackets, we actually write what is going to be the link on which people gonna click. In the round brackets, we provide the link.
[Visit Google website](https://google.com “Google”)
Images
There are two ways you can add an image to your GitHub repository.
First way: In the first way we have to open an issue then drag and drop the image you want. Then after it will generate the image URL.
So, here we get our image path and now we will copy this image path and paste in the src attribute of <img/> in the README file.
<img src=”https://user-images.githubusercontent.com/41661723/61168740-4c81b580-a570-11e9-8710-0e6b665860a4.png" width=”50" height=”50"/>
Second way: We have to use the syntax. ![img-name](img-path)
![git](https://user-images.githubusercontent.com/41661723/61168740-4c81b580-a570-11e9-8710-0e6b665860a4.png "GIT")
Fenced Code Blocks
The basic Markdown syntax allows you to create code block by indenting lines by four spaces or tab. If you find that inconvenient, try using fenced code blocks. Depending on your Markdown processor or editor, you’ll use three tick marks ( ```) or three tildes (~~~) on the lines before and after the code block. The best part? You don’t have to indent any lines!
```
{
"firstName": "John",
"lastName": "Smith",
"age": 25
}
```
Syntax Highlighting
Many Markdown processors support syntax highlighting for fenced code blocks. This feature allows you to add color highlighting for whatever language your code is written in. To add syntax highlighting, specify a language next to the tick marks before the fenced code block.
```javascript
var name = "Amit"
console.log(name)
```
Tables
To add a table, use three or more hyphens ( — -) to create each column’s header, and use pipes (|) to separate each column. You can optionally add pipes on either end of the table.
| Syntax | Description |
| ------ | ----------- |
| Header | Title |
| paragraph | Text |
Alignment
You can align text in the columns to the left, right, or center by adding a colon (:) to the left, right, or on both sides of the hyphens within the header row.
|Syntax|Description|Test Text|
|:--- | :----: | ---: |
|Header | Title |Here's this|
|Paragraph | Text |And more |
Blockquotes
You can create blockquote with greater than symbol ( > ). If you want nested blockquote use (>>)
> Keep smiling and work harder.
>> Peace
Horizontal Rule
Three or more...---
Hyphens***
Asterisks___
Underscores
Lists
1) Bullet List
* Bullet list
* Nested bullet
* Sub-nested bullet etc
* Bullet list item 2
2) Numbered list
1. A numbered list
1. A nested numbered list
2. Which is numbered
2. Which is numbered
Checkbox
- [ ] An uncompleted task
- [x] A completed task
After adding all the information about your project. Now, you can commit the changes.
After committing your README file will be added to your project.
I hope you got some useful knowledge about the Git stash and README file.
If you enjoyed the blog, give me clap 👏 and share it :)
Thank you.