DEV Community

Cover image for Little bit Git...
\144\150\162\165\166(dhruv)
\144\150\162\165\166(dhruv)

Posted on • Edited on

Little bit Git...

Getting started head on...

git log

I was working on some project, the conflict error occured again and again while I was trying to push. So, I decided to use rebase and move ahead with the problem but I needed to git see the commit history before I could use git rebase so what command did I use back then?

Before you move forward!!!

Think hard...

The answer is this👇

git log <branch-to-rebase-onto>..HEAD
Enter fullscreen mode Exit fullscreen mode

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(it's a Virtual Machine Environment in simple words). 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?

The answer is this👇

git stash
Enter fullscreen mode Exit fullscreen mode

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

git stash pop
Enter fullscreen mode Exit fullscreen mode

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:
git checkout -b new_branch_name
Enter fullscreen mode Exit fullscreen mode
  • Apply Stashed Changes:
git stash apply
Enter fullscreen mode Exit fullscreen mode

or

I can use this👇

git stash branch new_branch_name
Enter fullscreen mode Exit fullscreen mode

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:

git push origin <tagname>
Enter fullscreen mode Exit fullscreen mode

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👇

git diff --cached
Enter fullscreen mode Exit fullscreen mode

If you have any feedback, then you can DM me on Twitter or Linkedin.

Top comments (0)