Stranice

Wednesday 6 June 2018

Git workspaces explained

Working in git is complicated for new users. One of the reasons is that it is quite hard to grasp where are some actions happening.  Although some actions can be done from local to remote workspaces they are not recommended. The reason is that when we expose our code changes to other we cannot perform actions that we would do like we do it locally. All those actions will be mentioned in this article with short description and explained with greater detail in subsequent articles.

Working areas in git

  1. Working directory
  2. Index (Staging area)
  3. Local repository
  4. Remote repository

1. Working directory

The area where we edit our files.

2. Index (Staging area)

The area where are the files ready to commit to our local repository.

3. Local Repository

 The are where we put code we think we have finished editing.

4. Remote repository


If we just put our code to remote repository we might consider it as backup, or if we interact with others we have an additional step.

Local vs Remote workspace

Also we need to separate what actions we perform on our computer (locally) or with others. Remote workspace can be defined as some other repository on the same computer, network storage, remote computer or dedicated service like github, bitbucket, gitlab, .... It is

Local workspace

We can define local workspace as everything we do using our computer without any interaction with remote code. In that area we can put following workspaces: working directory, index and local repository.

The usual workflow in local workspace is following:
  • Putting into local repository
    We create code and add it into the staging area, we can check the changes we are  about to put into the local repository.
  • Getting out of the local repository
    We get the code from the repository into our working directory

Remote workspace 

I would define remote workspace how we have interaction with others. So it is interaction between our local repository and remote repository.

The usual workflow in remote workspace:
  • Putting into remote repository
    - single-user
      Just put code into the the remote repository
    - multi-user
      Create a request to put code into the remote repository, 
      some other user needs to accept it after making a code review
  • Getting code from the remote repository
    There are two steps involved: fetching and merging the code.
    First we fetch changes, see what has been changed, and merge to our local repository.

This is only introductionary post about git workspaces.

No comments:

Post a Comment