I consider myself a Git fan, but …I’m not an expert of Git.
Commit, fetch origin, pull origin, push to origin… that’s my day-to-day of using Git.
And I do some Git:
The advanced things that Git can do blow my mind. It can be very complex, and I tend to avoid all that complexity. I almost never use Git in the command line, and use GitHub Desktop which is the simplest and nicest Git client ever.
Two things I do however use sometimes are cherry-picking and squashing commits.
Let’s talk about that.
#git guide #git cheat sheet #github desktop
Git has become ubiquitous as the preferred version control system (VCS) used by developers. Using Git adds immense value especially for engineering teams where several developers work together since it becomes critical to have a system of integrating everyone’s code reliably.
But with every powerful tool, especially one that involves collaboration with others, it is better to establish conventions to follow lest we shoot ourselves in the foot.
At DeepSource, we’ve put together some guiding principles for our own team that make working with a VCS like Git easier. Here are 5 simple rules you can follow:
Oftentimes programmers working on something get sidetracked into doing too many things when working on one particular thing — like when you are trying to fix one particular bug and you spot another one, and you can’t resist the urge to fix that as well. And another one. Soon, it snowballs and you end up with so many changes all going together in one commit.
This is problematic, and it is better to keep commits as small and focused as possible for many reasons, including:
Additionally, it helps you mentally parse changes you’ve made using
#open source #git #git basics #git tools #git best practices #git tutorials #git commit
Rebasing is one of the two Git processes of integrating changes from one branch to another.
While merging always moves a branch forward in history by simply adding a new commit representing each branch integration, rebasing can be much more powerful (and dangerous) as it allows us to rewrite history.
Rebasing is the process of moving or combining (i.e. squashing) a sequence of commits to a new base commit.
Imagine you’re working on a feature branch and after some time you realise the main (aka “master”) branch has been updated by someone else’s code. This means your branch has now diverged from the main branch. At some point, you will want to include said changes in your feature branch. A common way of doing this would be to simply do a git pull from main which would add a merge commit to your feature branch.
#git #git-rebase #github-actions #git-commit
There are many ways of working with git, if they’re clean, and don’t do damages, probably most of them are good.
But same as space vs. tab, in the IT world is a war between fans of rebase, and fans of git merge.
There are tons of arguments about:
-Which way is better?
-Which one is cleaner?
-Which is more comfortable?
-Which one gives a cleaner git graph?
-Why it’s important, and which one is more dangerous?
#quick help #tutorials #git #git branch #git commit #git interactive rebase
There is no doubt that Git plays a significant role in software development. It allows developers to work on the same code base at the same time. Still, developers struggle for code quality. Why? They fail to follow git best practices. In this post, I will explain seven core best practices of Git and a Bonus Section.
Committing something to Git means that you have changed your code and want to save these changes as a new trusted version.
Version control systems will not limit you in how you commit your code.
But is it good? Not quite.
When you do an atomic commit, you’re committing only one change. It might be across multiple files, but it’s one single change.
Many developers make some changes, then commit, then push. And I have seen many repositories with unwanted files like dll, pdf, etc.
You can ask two questions to yourself, before check-in your code into the repository
You can simply use the .gitignore file to avoid unwanted files in the repository. If you are working on more then one repo, it’s easy to use a global .gitignore file (without adding or pushing). And .gitignore file adds clarity and helps you to keep your code clean. What you can commit, and it will automatically ignore the unwanted files like autogenerated files like .dll and .class, etc.
#git basics #git command #git ignore #git best practices #git tutorial for beginners #git tutorials
This article is part of a follow-along series on GitHub collaboration. In this article, we will try to understand commits in detail, like components of a commit, how to delete commit before and after push or how to reset it.
If you are a beginner and want to understand the practical application, I will recommend a quick read into the article, Collaborate on GitHub like Pro: **Part1 **before you start with this article.
The series, Collaborate on GitHub like pro, focus on specific topics:
Commits are created with the git commit command to capture the state of a project at that point in time. When you make a commit, Git stores a commit object that contains a pointer to the snapshot of the content you staged (indexed), please see below commit stage highlighted in red box.
Let us take a look into the commit object, shown below. I have highlighted the three main components in the commit, hash, head and branch (master).
Hash: Every commit creates unique hash for the respective commits. These hashes can later be used to revert to that version or find details on the commit. Usually, only the first 7 characters are used to look for respective commit.
Head: Shows which branch you are working on currently. In the above image, head is pointing to master, which means currently you are working on the master branch.
**Branch: **By default, the first line of development (branch) is named as master. All the preceding work on different branches gets merged to master.
To understand this concept further refer to this blog post.
Master branch after three commits
There are multiple ways to checkout to a specific commit based on the use cases. You might want to make a temporary or permanent switch. Sometimes you might want to go a few steps back and maybe add a feature from that step onwards.
#commit-git #git-revert-commit #checkout-git #show-heads #git-delete-branch