First step with Git
Tags: git, github, beginners, devlive
Published: 2020-06-09 15:53:36


Constantly we do things like download a movie, upload a picture, update our status, edit a post and send an email to somebody, which are actions similar to using git commands. Although, when we come to take a look at the command line, we have a hard time to use commands like git pull, git push, git status, git commit and a pull request. Some simple acts become hard to grasp because of the strange words. However, we will never learn without practice. Github is a social network like Twitter, the difference is we don’t have buttons to everything and even if we have an interface like Gitkraken it is important to know what we are doing exactly.First, we need create a Github account and create a new repository.

<img src="https://lh4.googleusercontent.com/QR2ej-Twwm5E4ZwXZkEQLkU787NvaIdxM1M3n6jBC1V0XsyJJrGpTLq_uzRp5bQTUcyvtDZWZemV-REPjxZPcojSp0tPDm5Bq3-0wHTbzon6gqUms5QBWH4LMhGgeiKOvBcX7usN" alt="IMAGE ALT TEXT HERE"  border="0" >
      <h6><center>Fig 1. Creation of a new repository.</center></h6>
________
Basically, to develop your project you need install Git with three option available agreeing with you SO.
```
 Windows: 
   Download the installer from site.
 Linux (Debian/Ubuntu):
   apt-get install git.
 MAC:
  Brew install git.
```
Now, you can copy the link of the repository and use the command git clone or if you prefer, you can download the repository directly. Before you need to configure your user:
```
Git config --global user.name “kaline”
Git config --global user.email “mesquitabfkaline@gmail.com”
```
Right after, to get started we should know some basic commands:
<img src="https://lh5.googleusercontent.com/pZIavDes-6TjqDTwmBo0HG-gwxB1I3P5xF9HHzzzn0xVkuqw6La-7V5-E0r0no714q_zCGNXbbFIrx6KfdUIM1O6bHypGTN5J1G1OJAXqQxATyxySsEBoV455VSuiESZDLVTJMou" alt="IMAGE CMD"  border="0" >
      <h6><center>Fig 2. Running initial git commands.</center></h6>
_____
<a href="https://git-scm.com/docs/git-config">git config</a>— get and set repository or global options. This means it is possible to define user credentials to each directory created locally.
<a href="https://git-scm.com/docs/git-init">git init</a> — creates a new Git repository or initialize a empty repository. Usually, this is the first command we run in a new project.
<a href="https://git-scm.com/docs/git-status">git status</a> — displays the state of a working directory and the staging area.
<a href="https://git-scm.com/docs/git-pull">git pull</a> — updates the changes from the remote repository to the local.
<a href="https://git-scm.com/docs/git-add">git add</a> filename or dir-name   —  moves files or directories to be fixed soon to the remote repository.
<a href="https://git-scm.com/docs/git-add">git add</a> . — moves all the files you changed to be in the future, to the remote repository soon.
<img src="https://lh3.googleusercontent.com/XiwoEgaVbM9IYtG7wieQwj8F1PH0-VG2YTsJL7F0qlz7diAZrQmXjQGNZPhqkuDHJZo1veZkYlJWNFa8I8Z9MRPNlmTeYeWxhUbS8xMC" alt="IMAGE CMD"  border="0" >
      <h6><center>Fig 3. Running git commands after registered changes.</center></h6>
_____
<a href="https://git-scm.com/docs/git-commit">git commit</a> — Registers changes to the repository. This means this command is used to create a log to each change from the local to remote repository.
<a href="https://git-scm.com/docs/git-commit">git commit</a> -m “message” — Registers the local changes with a message to explain the modification.
<a href="https://git-scm.com/docs/git-log">git log</a> — shows the history of commits classified with time. 
<a href="https://git-scm.com/docs/git-push">git push</a> — updates the remote repository using the local references.

Finally, we can see the changes in the remote branch master.

<img src="https://lh6.googleusercontent.com/20VjBGZBaQeCgzRZCVwBqlGa7o1x3PJBVeZWprK4eTIgY3A2i4_wflj-jR20zG0AjoBj4YDrX_2sJqtBrX5Y52IYaE5hah8MXZ_lXzST" alt="IMAGE CMD"  border="0" >
      <h6><center>Fig 4. Branch master before run command 'git push'.</center></h6>
_____

<img src="https://lh4.googleusercontent.com/G6RkzVNxm-1M8bDO6Q-10krW45CI0xe8vdcEDewA-iELhn5PNvPcaIFpZL0XGHMfiaCIrKk4DdoojgimaA9MJCA94m8r6eUiTS465-IU" alt="IMAGE CMD"  border="0" >
      <h6><center>Fig 5. Branch master after run command 'git push'.</center></h6>
_____