Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the relationship between Git and Stash?

I can access my company Stash project repositories. I cloned the project into my local Git repository through Eclipse IDE. For that, I installed required Git plugins into Eclipse.

My questions are:

  • Git is just a facilitator to communicate with Stash?
  • Can't we use Git as distributed repository instead of Stash?
  • What is the relationship between those two tools?
  • Without Git, can the code be cloned, committed to Stash? Or, without Git, can Stash exist?
like image 463
Vinee-the-Pooh Avatar asked Aug 30 '15 08:08

Vinee-the-Pooh


People also ask

Is stash and git same?

The git commit and git stash commands are similar in that both take a snapshot of modified files in the git working tree and store that snapshot for future reference. The key differences between the two are as follows: A commit is part of the public git history; a stash is stored locally.

Where are stashes stored git?

All are stored in . git/refs/stash . git stash saves stashes indefinitely, and all of them are listed by git stash list . Please note that dropping or clearing the stash will remove it from the stash list, but you might still have unpruned nodes with the right data lying around.

Why should I use git stash?

Use git stash when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the HEAD commit.

What is git checkout and stash?

The stash command cleans up the working repository, reverting it to the last commit. Stashing changes allows users to run other Git commands, such as checkout or pull , or to switch to a different branch without causing a mess on the main branch due to unsaved changes.


1 Answers

Some brief information about Stash and Git.

Git is a distributed version control system.

Stash is a repository management system of Atlassian. It can be used to manage Git repositories, also it can be used to manage repositories of other version control system like mercurial.

A good overview for each product can be found in their official sites;

Git official site, about page

Atlassian official site. In September 2015, Atlassian renamed their Stash product to Bitbucket Server.

There are many repository management system you can use with Git. One of the most popular is Stash in Enterprise world. But when you look to open source world, GitHub is the most popular one as far as I know.

You can create repository, push, or pull your code into Git repositories whether they are in your local computer or they are in remote corporate servers. Using a repository management system ( like Stash) for this kind of task is not necessary, but It is sometimes preferred, especially by the companies which has huge It departments.

So, Git, and Stash are not alternative but complementary to each other. You can think Git as a kernel and stash as the shell surrounding the kernel.

But, why we need repository management systems;

  1. Security; huge corporates wants to manage who can access which projects source file with what restrictions. Git can not handle this, it is just VCS.
  2. Administration; You can integrate with corporate LDAP system, You can manage user easier.
  3. Integration; You may have Jira for issue tracking, bamboo as build server and confuluence as wiki. And you can easily integrate them because all of them Atlassian's tools.
  4. Ease of use

Now, Lets try to answer your questions;

I can access my company Stash project repositories. I cloned the project into my local Git repository

Whether Code repository is on remote server behind stash or it is in local computer. It is a Git repository.

Git is just a facilitator to communicate with Stash?

No, Vice versa is more correct. Git is the core of VCS, you use stash to make it more manageable, secure, and easy to use in your corporate.

Can't we use Git as distributed repository instead of Stash?

First you can not use Git instead of Stash, because they are not alternative to each other. But they are complement to each other.

If you mean using Git as remote repository, sure you can use it.

For clarification, Git is distributed not because you can have remote repositories. Whether centralized or distributed, you can have remote repository on all VCS. Distributed means, when you clone a repository, you also clone all history etc. In this structure, you can have a central repository but it is not required. If centrol repository get corrupted, it is not a big deal, any node can become new central repository. Even though in corporate world having a central repository is best practice, some open source projects ( for instance Linux kernel) don't have a central repository.

What is the relationship between those two tools?

I think it is already explained above. They are complementary to each other. Git is the VCS, and stash is repository management tool. It makes Git more secure and manageable for corporate IT departments.

Without Git, can the code be cloned, committed to Stash? Or, without Git, can Stash exist?

It is already explained as well. You can use Stash with other VCS. Git is not necessary. But you need at least one VCS.

You can not commit/clone code to/from stash. You can commit/clone code to/from VCS via stash.

VCS: Version Control System

like image 76
clockworks Avatar answered Sep 29 '22 06:09

clockworks