miércoles, 18 de noviembre de 2020

GIT Demystifying part 1

 GIT demystifying part 1


  This Diagram shows the basic different git commands to change the state of the files.


References: https://git-scm.com/

Requirements: Git installed

  This Lab demystify by example what happen when git commands are applied. Start with basic commands and see the efects of this command over the different states of Git, this are the Working Directory, the Stage or index, and the History or the Commits.

On this particular case, we use a directory created by an Ide (IntelliJ), so this directory has some files and directories that are not relevant to be considered over the development of this lab, so we use the .gitfile ignore to add this exclusions. simply after create de project with the ide, in the main directory of the project we create the .gitignore file with the next content that can be modified accord to our needs.

file .gitignore :
.gitignore
.idea
.iml
src/

this will leave the git status info clean of files that don´t want to be treated on this lab. Also config the git with personal info, this must be personal accord to each one. this is the name and email that is registered along the commits history.

Config Git

  Open file explorer and select the directory of work, right click over it -> Git bash Here, on this console type the git commands: 

git config --global user.name "jalbertomr"
git config --global user.email "jalbertomr@yahoo.com"
git config --list

1.- Work with file1 create, add and commit

  We will work with one file, first our directory has some native files that own to the project and ignored thanks to .gitignore file.

bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ ls -a
./  ../  .git/  .gitignore  .idea/  gitLab01.iml  src/

This is a very simple case where create a file1 is added to Stage and Commited.

In Detail the same commands with console response, and showing the result of
git status 
git diff                   : shows the difference between Working Dir and Stage. 
git diff --staged     : shows the difference between Stage and History.

check the color of the unatached file1 in orange and the same file attached by add command change to green. and finally with git log the commit appears.


2.- Work with file2 create, move it from Working Dir to Stage, from Stage to Working Dir and delete it, and never commited.

   Lets create file2 then add it, once staged, return it to unstaged condition to finally remove it, so never commited.


Detailed operacions in console

  The important here is to see that once the file is in Stage, the command git diff --stage, report de diference between Stage and History.


eot

No hay comentarios:

Publicar un comentario