Git basics

in #git5 years ago (edited)

Hi friends,

Today I will be given a few insights on git which is a great control version system or cvs that helps develop projects with remote peers and interact with the same codebase without blocking each other or waiting for someone else work.

If you have never used git I would highly recommend taking this codeacademy course it is free and teach you the basics. I must admit that when I started using git was really changing coming from a subversionn world where everything was done differently.
I've seen that we tend to use few commands that we actually need but I will try to explain that in a video that I will be uploading later on.

Git basic commands

git clone

This is usually the first git command you will most likely perform. It is how you will get a remote repository and clone it locally as we call it local repository. Starting from this, you will have to get used to get everything from remote and send everything to remote. This is pretty much the description for the next 2 commands.

git pull

Get everything from the remote repository syncing the references with the remote onces (not really perfoming the changes) as you should perform git pull in the branch you want to update to actually get the changes. Changes on other branches will not be performed but a message will show up saying you are X amount of commits behind.

git add

Usually once you add new files or modify existing files your changes have to be marked as good to add to remote repo. This just starts the send process to the local branch and then to the remote.

git commit

Pretty much splits changes and set them a meaningful message to let know other developers what the change is and why you have done it. The idea with each commit is to isolate changes that add new functionality and are easy to read and understand, hence why I will talk about rebase and squash later on.

git push

Once you have a batch of one or more commits ready to go from your local repo to remote or origin, you have to push them to the configured remote url that can either be (github, gitlab or any other service).

git checkout

This commands serves to purposes, the first is to undo local changes with what ever changes were at the beginning pulled from remote. Second usage is when you add a -b flag creating a new branch with changes from the previous branch. Pretty neat feature to start working on unfinished features that are frequently updated and then you can get the changes as you re doing your own stuff (pull and rebase require, there is another option that we could use called cherry-pick)

git branch

Lists, create and delete branches, the most common usage is to list and delete branches.

git rebase

This is the most useful command to sync, redo history log and get commits and history as you wish readers to see it. Pretty useful to get those debugging and development commits once pushed (ideally they never made it to the remote branch/repository)

git log

Show the history of the commits for the branch you are standing on top.

git config

It is useful for setting up user.name and user.email if you have never set it up or also the remote url.

git reset

This one undo and gets to an stable known commit forcing changes to be undone and removed.

I would like you to take a look at the video that will be linked soon. Thanks for reading.


Dtube video tutorial -> https://steemit.com/git/@raserrano/v0kg0eus

Sort:  

This topic can be confusing. Consider adding command examples next time, perhaps even some graphics for more complicated things such as git rebase.

Posted using Partiko Android

Took ages to get it uploaded but here is the video.
https://steemit.com/git/@raserrano/v0kg0eus

Hello! Your post has been resteemed and upvoted by @ilovecoding because we love coding! Keep up good work! Consider upvoting this comment to support the @ilovecoding and increase your future rewards! ^_^ Steem On!

Reply !stop to disable the comment. Thanks!

Coin Marketplace

STEEM 0.29
TRX 0.12
JST 0.033
BTC 62559.43
ETH 3092.10
USDT 1.00
SBD 3.86