learn programming

How I use Git

rynek z mostu grunwaldzkiego

Git hit my ears a few times before I even decided to jump into learning programming. I’ve even heard that some people use Gita to prepare presentations. It intrigued me, but never enough to learn Git. All in all, Git was only associated with GitHub, but it’s not the same. How is it now?

How did it start?

At first, I didn’t plan to start learning programming from Git at all. I thought that I would learn it once I had a little bit of solidified the basics of programming. After all, Git is mainly used in companies? Well, no. I’m learning Python from the book Move Your Head series. A book is like a bomb for me.

The problem, however, is that the further into the book, the easier it is to get a bug in the code and something doesn’t work. Then nervous attempts to correct the code and it does not work even more. Damn, how do you go back to the previous state? Rewrite everything from scratch? What a waste of time. Is there any cure for this? And no is Git? You had to stop learning Python and jump into the Git course.

Personally, I recommend the “Git Course” prepared by Maciej Aniserowicz. Everything is laid out in an accessible form, and easy to assimilate. Starting the course, I had zero knowledge about Gita. A dozen or so hours later, not only do I know what it is about, but I can also solve conflicts at the merge and order a remote repo. Of course, this is not a level pro, but it is calmly enough for current work with the code.

How do I use Git?

git works schema
Programmers work with Git, Isometric vector illustration

After creating a dedicated catalog for the project, I immediately start the git bash console, go to the created directory and enter the command

Git init – git from now on tracks changes in the indicated directory.

The second step is to prepare a remote repository. So far, I’ve been using Dropbox for this purpose, but I’m wondering if I should upload more projects to GitHub. I have some ideas for web applications that will help specific groups of people and maybe someone might want to help with their creation. It will always be easier to share the code with GitHub. In any case, the remote repository teaches group work and is a great backup of my projects, so I heartily recommend it.

Git commit

For each code modification, I create a dedicated branch using the command:

Git branch

In such a branch I make changes, and after each change, I pass to Gitand information about what has changed using commands

Git cadd and git commit with corresponding comments.

At the end of the working day, as everything works, I merge the working branch with the master branch with the git marge non-FF command and send the changes to the remote repo – git push. Locally, I delete the working git branch -d, and the work history is beautifully saved.

And that’s it?

Actually, yes. Working alone, so much knowledge about Git is enough. Well, except for one more element. As it turns out, even alone you can provoke a conflict. Then the configured GitTool tool comes in handy. A simple and efficient tool is WinMerge. As for me, enough to resolve the conflicts I encountered without any problems. Interestingly, WinMerge can also be used to track changes in text files. Let’s say you’re preparing project documentation. Then you sent for an opinion and you get back with the changes, but no information about what exactly has changed. WinMerge will show you these changes.

What does working with Git give me?

Two main benefits:

– I don’t have to nervously solve code problems when I think I’ve made changes to the code according to the instructions in the course. Just go back to the last working commit and save your changes.

– I’m learning to work with Git, which will definitely be useful when I have to work on a project with colleagues.

Git – Like it?

PS. Sometimes, I met a problem Loading repo to Git

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

X