# Little bit Git...

Getting started head on...

## git log

Suppose you are working on some project, the conflict error occured again and again when you were trying to push. So, you decided to use `rebase` and move ahead with the problem but you needed to git see the commit history before you could use `git rebase` so what command did you need to use?

```bash
git log <branch-to-rebase-onto>..HEAD
```

where `<branch-to-rebase-onto>` is replaced with the branch where I have to rebase it onto(generally it's `origin/master`)

## git stash

I was trying to setup an environment for some open source project, which needed installation of **Vagrant**. While doing the setup of the environment, I went through several Errors!  
I solved some with the help of my helpful brother and some on my own but then in the end, I figured out that some Changes that I made in my configuration file for Vagrant were not suitable for pushing to the origin of the main repository for that open source project.

*In Short, there were some Changes specific for my own system(not suitable for a public repository)*

Now I needed to add my changes to git commit without adding that configuration file, which command did I use to ignore that particular file?

```bash
git stash
```

If you want to reapply the changes back to the working directory, use this command👇

```bash
git stash pop
```

## Stash Apply

There was a time when I wanted to restore some previously stashed work to a new Branch using git, How did I do it?

The answer is this👇

* **Create a New Branch:**
    

```plaintext
git checkout -b new_branch_name
```

* **Apply Stashed Changes:**
    

```plaintext
git stash apply
```

or

I can use this👇

```plaintext
git stash branch new_branch_name
```

where `branch` and `new_branch_name` are the branches from which you are taking stashed changes from and the branch you are pushing it to respectively

## Tags:

Tags are necessary to mark specific points the history of the commits!  
Releases are one important example

To push tags to a remote repository:

```plaintext
git push origin <tagname>
```

replace `tagname` with whatever tag you want to paste

## git diff:

To review the changes that are currently staged (in the index) before committing them, use this👇

```plaintext
git diff --cached
```

Thanks 🤟 for reading the article!
