Git & GitHub command reference

Installing git in Ubuntu

Configure git

Checking the git configurations 

Create an empty git repository locally

Staging files for commit

Commit files locally

Checking commit history

Checking the status of your files

Checking diff

Renaming a file in git

Removing files from git

Unstaging a Staged file

Discarding changes done to a file 

Ignoring certain types of files from getting committed accidentally

Undoing the most recent commit 

 

Let’s assume you are currently working on a medium priority bug fix but the fix is in progress, suddenly you get a show-stopper critical issue.  In this situation, you can’t commit your current changes done for the medium priority bug fix as it isn’t complete yet, at the same time you can’t discard your changes as you would have put many hours of effort.  This is where git stash helps you park your current code changes in the repository without committing them.  Once you have stashed your changes done part of the medium priority issue, your repository will look clean, allowing you to focus on the critical issue.  Once you are done with a critical fix, you can resume your work on the medium priority issue.  By the way, there can be many stashes and stashes work like a Stack as the most recently stashed changes appear in the top.

Stashing code changes

Listing stashes in your repository

Resuming back to a stashed changes

But git apply stash@{0} wouldn’t remove the stash from the repository as it would expect you to drop that from the repository manually.

Removing a stash from the repository explicitly

Git Pop will apply the topmost stash and remove it from the repository in a single step

Delete all stashes at one shot

Creating a git branch 

Switching to a branch

Creating a new branch and switching to it at one-shot

Merging changes from feature-branch to master branch

Deleting a branch

Clone a remote git repository

Pushing changes from local to remote repository

Pulling delta changes from GitHub to Local Repository

 

Share Now

Jegan

More Posts By Jegan

Related Post

Leave us a reply