Git basics to improve your teamwork

If you are like me and you are entering to the world of tech, programming, working in teams and many other options you are in the right place! I will tell you about Git, a tool that save my life and I wish I would have used it before because is for sure life changing.

I will give a brief explanation of what is git and how it is used:

First thing’s first: What is Git?
Git is a version control system, most frequently used by developers and one of the most popular ones!

  • What is Version Control?
    Is a way that “we” all programmers trap our code changes. We track our code from the beginning and record every update made, we save each step into git. As the name says, we use Git to control every version of our code.
    This gives you a clear view of all of the changes we have made in our code through time so we can see and understand what we did, we can track bugs or go back to previous versions of our code if we need to.

Git is also a great way to get started with the command line! If you are not used to it this will get you on track.

Git Basic Commands

  • Git Clone: for bringing a repository that is hosted somewhere into your local machine.
>> git clone <your_repository>
  • Git add: for when we update, create or deleted files, it can also be folders. We use this command to tell git that we made changes, in other words to track your files and changes in Git.
>> git add . #This will add every change made
  • Git Commit: to save the changes we made in our code.
>> git commit -m "fix: right variable name"
  • Git Push: Once we made changes and we are ready to put them or upload them we use this command, this will upload everything you add and commit to your remote repository, like Github.
  • Git Pull: we use this command to bring every change from our remote repository to our local machine, is the opposite of push.
  • Git Status: shows all of the files that were changed, updated, created or deleted in your local repository.

Knowing this basic command you are ready to improve your teamwork with Git

Now I will tell you my best advices to use all the benefits that Git gives you!

  1. Formalize Git conventions for your team
    What do I mean with this? Let’s take the example for when we save a file in our computer, maybe we can name it , we as the owner of this file we will know what this means but if someone enters to our computer will have no idea what that image is. That changes if you name the image to , now you gave that image a standard and descriptive way of what it is inside.
    Well, Git works similar, it is necessary to establish this standard conventions for branch naming, tagging and coding for your team and follow it as arranged.
  2. Merge your changes properly
    Each member of the team should work on a separate branch. When working in different branches it can happen that you work in some common files and eventually merging it to staging or master.
    You should consider learning Git merge techniques like resolving conflicts and using a text editor that support doing this merge options.
  3. Use tags
    After you or your team are done testing and ready to deploy from your current branch or if you want to preserve the current state as a significant milestone you should create a Git tag.

A tag is a snapshot of the branches state at that instant.

You can add your tags with the next command:

>> git tag milestone-id -m "short message saying what this milestone is about">> git push --tags

4. Code reviews through Pull Request
A pull request is a request to merge code from a branch to another, this summarizes the comparison between the two branches in question and initiates a discussion between the developer and the organization admins.

Pull request is a way to check your team works and to review any required change before they merge any branches or move through the Git flow.
In other words, is like telling your friend to review your essay spelling, he will let you know any mistakes or changes you need to make so you change it and then send the final corrected version.

This are my four fundamental recommendations to improve your Git game, there are many other you can explore online but this are my favorite ones that have change the way I work with my team.

I hope this works for you!