Category: Distributed Version Controlling

All about Git – “Git Stash” Part – II

In this post, I am going to discuss on a very powerful command “git stash”. It is a very powerful command and that is why I want to dedicate a single blogpost discussing only about this important command.WHAT IS GIT STASH:This command will temporarily shelve the changes you’ve made to your working copy so that you can work o something else, and then come back and re-apply those changes at later point in time.HOW TO STASH YOUR WORK:The command git stash takes the uncommitted changes (both staged and unstaged) and saves them away for later use, thus reverting them from your working copy.For example, I have two files “test.txt” and “NewOne.txt”. Out of these two files, “test.txt” is staged and ready to be committed whereas the file “NewOne.txt” is yet to be staged.So if I issue the command git status, below is the result -Now if I issue the command git stash, let’s see what happens -So if I open the file, I will notice that all my changes to these two files are gone. But where? How can I get those changes back? So many questions!! :-) I will come into each of these questions slowly.One important point to tell here is that stash is local to your Git repository; stashes are not transferred to the server when you push.HOW TO RE-APPLY THE STASHED CHANGES:One can re-apply the stashed...

Read More

All about Git – Cheat Sheet – Basic Part – I

WHAT IS GIT?In today’s world, the most widely used modern version control system is Git. Git is a mature, actively maintained open source project originally developed in 2005 by Linus Torvalds, the famous creator of the Linux operating system kernel.SETTING UP A REPOSITORY:Git uses the below command to create a new Git repository.git initExecuting this command will create a .git subdirectory in the project root and transforms the current folder into a git repository.The below command will create a new folder named directory and initialize the repository by creating .git subdirectorygit init BARE REPOSITORY:The below command will create the bare repository.git init –bare The –bare flag will create a repository which is having no active working directory. This is very important. You should always consider creating your central directory as a bare directory and from there create all your branches (non-bare directory) where the developers will work. Once the work is done, developers will merge their code from branches (non-bare directory) to central repository(bare directory). Since the central repository is bare directory and does not have any active working directory, there is no chance of editing the files and committing them.CLONING AN EXISTING REPOSITORY:The git clone command copies an existing Git Repository. Cloning always creates a remote connection called origin pointing back to the original repository. This makes it very easy to work with the central repository.The below command will...

Read More

Earlier Posts

  • 2024 (32)
  • 2023 (47)
  • 2022 (25)
  • 2021 (35)
  • 2020 (41)
  • 2019 (13)
  • 2018 (16)
  • 2017 (14)
  • 2016 (18)
  • 2015 (74)
  • 2014 (20)