What is Git?
Widely known, as defined in Wikipedia, Git is a distributed version-control system for tracking changes in source code during software development. It was originally designed and developed by Linus Torvalds (creator of the Linux kernel) and is the most popular version control system to date.
It is equipped for enabling coordination work among programmers and data scientists, which can be used to track changes in any set of files. Its goals include speed, data integrity, and support for distributed and non-linear workflows.
Must-learn Git functions to get started
- Workflow
- Repositories
- Staging and Committing changes
- Undo
- Working with branches
- Sharing for collaboration
How to set up Git repository
Please follow the links below to download and setup Git properly.
After installing Git, please run these commands in order to set Git config.
Windows
https://gitforwindows.org/
Mac
http://git-scm.com/download/mac
- git config –global user.email your.email.add@shiftasia.com
- git config –global user.name “Your names here and inside quotes”
- git config –global core.autocrlf
Common Git Terminologies
Repository | Place where git stores information to manage project or a set of files as they change over time |
---|---|
Staging area | Place to keep track changes between repository and working directory |
Working directory | Place where you work with files & folders |
HEAD | HEAD is a reference to the last commit in the currently check-out branch (local branch). HEAD can be the last commit from branch or can be switch to any commit |
---|---|
* Commit hash * Commit Id * Revision number | SHA-1 checksum to identify a commit |
Basic commands in git
Checkout a repository | git clone </path/to/repository> |
---|---|
Add a file | git add |
Commit changes | Git commit –m “Commit message” |
Push changes | Git push |
Create then switch to a branch | Git checkout –b |
Switch branch | Git checkout |
Update and merge changes | Git pull |
Update changes | Git fetch |
Merge changes | Git merge / |
Revert local changes | Git checkout — |
Revert all local changes | Git checkout — . |
Create new repository | Git init |
Add a remote repository | Git remote add </path/to/repository> |
Reset whole branch | Git fetch origin |
Tagging | Git tag |
List commit logs | Git log |
Use more and Get comfortable
The shortest way to master Git is, to use it in projects. We recommend simulating a smaller group project, by creating files, naming it after the project, control branches and committing changes. Best practice includes adding an easy-to-understand commit messages. In a separate article, we will address naming convention for Git messages we use in projects at SHIFT ASIA – One of the leading software quality assurance companies.
For any inquiries, please drop us a message through contact form.
ContactContact
Stay in touch with Us