Git Tutorial for Beginners: Basic Git CommandsChao-Wei PengBlockedUnblockFollowFollowingMar 10Git is a very popular version control system for software development.
However, it’s not so easy for beginners to get a clear picture of how to use it in the project.
That’s why I write this beginner’s guide for you.
Before starting, we must have some basic knowledge about software development, including how to create a folder for a new project and use command line interface in your operating system.
Download and Install Basic Git Command Line Tool.
There are many great Git tools.
But, at the beginning, the only one you MUST have is the Git Command Line Tool which can be downloaded from Git website maintained by members of the Git community.
Go to download, and install it by just click next button in the whole process.
Download basic tool from Git website.
Use Git to Do Version Control Just in Local Machine.
Everybody tells you how to use cloud service like GitHub or Bitbucket to manage your project between local and remote Git repositories.
It’s good for practical use, but not for learning key concepts.
Try to start experiencing Git by using it just in local machine: initialize Git repository, check status, add files to staging area, and commit a new version, locally.
Initialize Git Repository.
In command line interface, be sure your working folder is set to project folder.
Then, initialize your Git repository by typing command below:git initIf nothing went wrong, you will get a .
git hidden folder in your project.
All the files in that hidden folder do the magic of Git version control for your project.
There is a .
git hidden folder in the project after git init command.
Check Status of Git Repository.
For building up your project, you may create new files, modify existed files, or add/remove assets.
Now, use command below to check what have been changed, and what changes have been staged for the next commit.
git statusUse git status to show unstaged changes.
Add Changes to Staged AreaAfter some hard works, you can see many unstaged changes when you try to check status of Git repository.
Before we can make a new commit into Git tracking system, we should add changes to staging area explicitly:git add .
You can see staged changes after git add .
Create a New Commit into Git Version Control SystemA commit means a bunch of changes, or you may say it’s a version of your project.
We group all the changes in the staging area into a new commit, and record it into Git version control system.
git commit -m “description for this commit.
”Repeat Steps Above.
View the Commit History.
We have learned the most critical part of Git version control system.
Just repeat 4 steps below to manage your project in the future development:Work on your project.
Check status of Git repository.
Add changes to the staging area.
Create a commit, including your changes, for future tracking.
You will get more and more commits in your repository.
So, it’s time to view the commit history.
Just try the log command to view the commit history:git logCreate a new commit and view the commit logs.
What’s Next?After you are familiar with these core Git operations, it’s time to sign up a new account in a cloud service, ex.
GitHub or Bitbucket, and create a mapping Git repository in the remote machine for cooperation with other developers.
You can start learning what’s branch, and how to handle local repository and remote repository by commands like clone, remote, push, and pull which are not covered in this tutorial.
Good luck and see you next time.
:).. More details