Git For Beginners
Learn what Git is, why it’s important, and 10 different commands
What is Git?
Git is an open source software that helps track and modify changes for projects using version control. It is a popular version control system that works with GitHub so that software developers can store and manage their programming projects.
Version Control
Version control is a system that serves as a way to review or make changes to projects, all done through a series of commands and a database of files. The database of files is called a repository, which holds the files and directories of previous work and versions of a project.
Importance in Software Development
Git and its distributed version control system helps multiple people work on the same project without changing someone else’s work using local branches. So, you can code part of a project on your computer (and on your branch), and another coworker can code their part of the project on their own computer on their branch.
Additionally, you can even review previous versions of a project you worked on and revert mistakes. Developers can review bugs from previous versions of applications. Git offers a structured system and environment to carry out various software development practices.
Ten Git Commands
1) git init
Initializes a Git repository from the directory you are currently in. Git will know to track any file changes in the location of this initialized repository.
2) git branch
Lets you create, delete, rename, or view branches.
3) git checkout branch-name
Puts you on the new branch branch-name.
4) git checkout -b new-branch-name
Create a new branch and go to it at the same time.
5) git merge
Helps integrate the changes made in one branch into another branch.
6) git status
Shows if any files were changed or saved by giving the state of any files that were modified or have not been pushed to a remote repository .
7) git add
Prepares any files that were changed to be committed in the working directory.
8) git commit -m “message here”
Records the changes made to any files with the ability to write a brief message about those changes.
9) git push origin branch-name
Pushes the changes made on a local branch (in Git) to a remote repository (to GitHub). This is done AFTER committing changes (from the git commit command).
10) git log
Shows the history of the commits in the repository. This command can help you find a specific version of a project.
Where to install
You can install Git directly from this website: https://git-scm.com/ . Be sure to download according to your computer’s operating system.
Where to practice
Don’t want to install Git but still want to practice? You can check out Git branching tutorials at this website: https://learngitbranching.js.org/ .
If you are just starting to use Git for the first time, it can definitely be a bit confusing. When I first used Git, I was so scared I was going to break something! I practiced the commands with a regular text file so that if things turned sour, I was okay with losing the file. The more you practice, the better you get so just keep practicing! Already learned one command? Awesome, you are one step closer to getting better at Git.
If you want more information on Git, I recommend checking out this free book about Git, written by Scott Chacon and Ben Straub at this website: https://git-scm.com/book/en/v2 .
Sources
Brief Introduction to Git. (n.d.). University of Iowa. Retrieved July 6, 2023, from https://homepage.divms.uiowa.edu/~luke/classes/STAT4580/git.html
Ernst, M. (2022, December 27). Version control concepts and best practices. https://homes.cs.washington.edu/~mernst/advice/version-control.html
Git and Github. (n.d.). Turing School. Retrieved July 6, 2023, from https://backend.turing.edu/module1/lessons/git_and_github