kaline
Posted on June 9, 2020
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.
Fig 1. Creation of a new repository.
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:
Fig 2. Running initial git commands.
git config— get and set repository or global options. This means it is possible to define user credentials to each directory created locally.
git init — creates a new Git repository or initialize a empty repository. Usually, this is the first command we run in a new project.
git status — displays the state of a working directory and the staging area.
git pull — updates the changes from the remote repository to the local.
git add filename or dir-name — moves files or directories to be fixed soon to the remote repository.
git add . — moves all the files you changed to be in the future, to the remote repository soon.
Fig 3. Running git commands after registered changes.
git commit — Registers changes to the repository. This means this command is used to create a log to each change from the local to remote repository.
git commit -m “message” — Registers the local changes with a message to explain the modification.
git log — shows the history of commits classified with time.
git push — updates the remote repository using the local references.
Finally, we can see the changes in the remote branch master.
Fig 4. Branch master before run command 'git push'.
Fig 5. Branch master after run command 'git push'.
Posted on June 9, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.