Learn git concepts, not commands

0
304

The general drawing contains 4 areas distributed as follows:

  • The development environment with:
    • Working directory
    • Staging area or index
    • Local repository
  • A server with:
    • Remote repository

At that time, you can explain the benefits of a distributed version control system.

Cloning a repository

When cloning a repository, the data from the remote repository travel to 2 areas:

  • Working directory
  • Local repository

Making changes in the working directory

There are 2 types of files in the working directory:

  • Tracked: files that Git knows about.
  • Untracked: files that have still not been added, so Git doesn’t know about.

Updating the remote repository

As changes are ready in the working directory, they must be added in the staging area.

When there is a set of changes with a single purpose in the staging area, it’s the time to create a commit with a message about that purpose in the local repository.

When there are one or several commits in the local repository ready to be shared with the rest of the world, they must be pushed to the remote repository.

At that time, you can talk about the different states of a file in the development environment: modifiedstaged and committed.


Furthermore, you can explain:

  • how to show the changes of a file in the working directorygit diff
  • how to show the changes of a file in the staging areagit diff --staged
  • how a file can be changed in the working directory after being added to the staging area
  • etc.

Updating the development environment

When executing git fetch, the data from remote repository only travel to the local repository.

Pulling

When executing git pull, the data from remote repository travel to 2 areas:

  • To local repositoryfetch
  • To working directorymerge

If you take care the commit history, consider the use of git pull --rebase. Instead of fetch + merge, it consists of fetch + rebase. Your local commits will be replayed and you won’t see the known diamond shape in commit history.

Main Reference – https://dev.to/unseenwizzard/learn-git-concepts-not-commands-4gjc?ref=heydesigner

LEAVE A REPLY

Please enter your comment!
Please enter your name here