Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git's local repository and remote repository -- confusing concepts

Tags:

git

repository

If I understand correctly, Git has two sorts of repositories: one called local, another called remote. My questions are extremely naive ones about the two types of repositories.

Is that correct to say

  • Git local repository is the one on which we will make local changes, typically this local repository is on our computer.

  • Git remote repository is the one of the server, typically a machine situated at 42 miles away.

Another question: some tutorial shows me this workflow

  • mkdir myproject
  • cd myproject
  • git init
  • touch README
  • git add README
  • git commit -a -m "

I see that git init creates myproject a local repository. What I don't understand is the git commit command. If I have not yet set a remote repository, how can Git know where to commit my README file??

I hope I was clear.

[EDIT] The way I am using Git might be different from others: I use a private Git repository to backup my codes. So I think I do need a remote repository. The local repository should be nonsense in this case. Am I right? Thanks for your clarification. These are the most naive questions that I cannot find replies anywhere else...

like image 712
zell Avatar asked Oct 25 '12 15:10

zell


People also ask

What is the difference between local repository and remote repository?

Local repositories reside on the computers of team members. In contrast, remote repositories are hosted on a server that is accessible for all team members - most likely on the internet or on a local network.

What is the difference between local repository and working directory?

The repository is essentially the . git hidden folder inside the working directory (workspace). The working directory (workspace) is essentially your project folder.

What is local repository and remote repository in version control management?

It is a place where all the modified files marked to be committed are placed. Local Repository. User's copy of the version database or file and access all the files through local repos and push the change made to remote. Remote Repository. It is a server where all the collaborators upload changes made to files.


1 Answers

As I'm experiencing exactly the same questions like yours (coming from VSS and TFS mindset) and during the last 3 days started to understand. I would believe that these kind of diagrams would be more helpful to understand the whole picture for anyone else trapped there.

from: https://greenido.files.wordpress.com/2013/07/git-local-remote.png?w=696&h=570

Git Flow diagram 1

Another one, from: https://wiki.lsr.ei.tum.de/lib/exe/fetch.php?media=nst/programming/git_flow.jpg&w=500&tok=e87798

Git flow diagram 2

like image 68
Bishoy Hanna Avatar answered Oct 02 '22 12:10

Bishoy Hanna