Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Git Terminology

Header Image

Ahoy there, matey! In the world of Git, there be plenty o’ terms and phrases that may seem foreign to ye. Fear not, for this article will give ye a proper overview of the terminology used in Git, including commits, branches, and repositories. By the end of it, ye’ll be a Git-savvy pirate, ready to navigate the high seas of version control with ease.

Commits

In Git, a commit be a snapshot of the changes made to the code in a repository. Think of it as a pirate’s treasure chest, containing all the code changes made since the last commit. Each commit has a unique identifier, called a hash, which helps Git keep track of it. When ye make changes to yer code, ye can create a new commit to store those changes.

Here be an example of how to create a commit in Git:

git add .
git commit -m "Added new feature to pirate ship"

In this example, git add . adds all the changes ye made to the code to the staging area. Then, git commit -m "Added new feature to pirate ship" creates a new commit with a message that describes the changes ye made.

Branches

In Git, a branch be a separate line of development that diverges from the main codebase. It be like a separate ship from the fleet, sailing in a different direction. Ye can create a new branch to make changes to the code without affecting the main branch. Once ye’re done with the changes, ye can merge the branch back into the main branch.

Here be an example of how to create and switch to a new branch in Git:

git branch feature-branch
git checkout feature-branch

In this example, git branch feature-branch creates a new branch called “feature-branch”. Then, git checkout feature-branch switches to the new branch so ye can make changes without affecting the main branch.

Repositories

In Git, a repository be a collection of files and folders that make up yer codebase. It be like yer pirate ship, containing everything ye need to sail the seas of coding. Ye can create a new repository from scratch or clone an existing repository from a remote location.

Here be an example of how to create a new repository in Git:

mkdir new-repo
cd new-repo
git init

In this example, mkdir new-repo creates a new folder for yer repository. Then, cd new-repo navigates to the new folder. Finally, git init initializes the folder as a new Git repository.

Conclusion

And there ye have it, matey! Ye now be familiar with the basic terminology used in Git, including commits, branches, and repositories. Remember, Git be a powerful tool that can help ye keep yer code organized and yer projects on track. With this knowledge, ye be well on yer way to becoming a Git-savvy pirate. So hoist the Jolly Roger and set sail on yer next coding adventure!