Common Git Commands
Git can be a pejorative for an unpleasant person. Make your experience with Git a nice one.
--
There are still developers who don’t use version control! One of the best things about being a developer is being so far ahead of other workers who have to battle against version control in Word (or similar), and live light-years behind the cooperation tools that programmers get to use each and every day.
Prerequisites:
- None
Terminology
Git: Git is a distributed version-control system for tracking changes in source code during software development
Concepts
Index — This is where files are placed that you want to commit to the git repository. Also known as the staging area.
Repositories — A repository is a file location where you store all of the related files for the current project. A local repository resides on your system, a remote repository (generally) lies on a remote machine. A code project can consist of multiple repositories across multiple accounts, but commonly is a repository from a single account. Repositories (also known as Repos) are recommended to be kept under 1GB.
Tracking — Git takes snapshots of the whole state of a project. A revision in the repository relates to the state of the whole project, rather than single files.
Staging area — often referred to as the index (as described above)
Commit — similar to a save or a snapshot of the current project. You set a message about the changes performed, and saves a revision of the code that you can revert to anytime in one click. Commits allow you to go back to this (named) state of your project at any point.
Working tree (Working Directory)— a working tree is a directory in your file system that is associated with a repository
The typical workflow for git:
- make changes tot he working directory
- git add filename (stage a file, to the Git index)