Hey, the new developer’s when we start a development we always come across a situation that, How to use Git for our daily development work? This involves questions like when to pull, push, commit and fetch, etc. we spend our head-scratching to know this and their orders or execution.
Git is a source code management software. Now, what does it mean? It is used to manage versions of code and files. It tells when the change was made?, who made the change? What the change was? And this is really helpful in the development and managing of large projects. For now, I think this is enough to know if we want to discuss more Git then please comment.
Say you are about to start your work and about to write some awesome feature/bug, so how will you proceed? Here are steps that you’ll take
Step one
Thus with our requirements, we can use this as a magical tool like with the below cases.
If you want to make changes from another developer in your development then just replace <BRANCH_NAME> with that developer’s branch name.
If you want to make all changes pushed by other developers then change <BRANCH_NAME> with master and you get all changes pushed by others in your branch.
Once you get the changes on your local machine you can work on your code and something awesome.
Now you are done with your work or your day, now what to do? This is a time to push these changes to your repository. Hang on here, before pushing your changes you need to add and commit these to your local machine. So we get another step here
Step two
Now we are done with adding changes. Now it’s time to commit these changes to the current branch
Step three
Now that we are done with committing changes then can we go ahead and push these changes to the repository? Well, ideally if you are working alone in a repository then you are good to go and push the changes, but if you are not working alone then you need to do the below steps as compulsory. Even if you are working alone then also doing the below step will make a good habit
Step four:
Its explanation is the same as explained in the first step.
Now that we have pulled the changes, we are ready to push the changes.
Step five:
With this step, we are done with today’s task/work and our 80% daily work of git.
In our development, we also perform one important thing which is code review 🙂
For this command, fetch comes in handy. The full command is
With this, we get a feature branch whose review needs to be done. Once you take that branch locally just checkout to that branch and perform a review.
This is pretty much all that we do during a day and this much we interact with git on our regular work. But git is not only this much. It has many more tools and tricks in it. If you want to have a discussion or detail about any other then comment and we will have that.