Some commonly used commands in Git

Git is a good tool for code management. Theoretically it can be employed for any file management, if you are not concerned about the disk usage. I have been using GIT to manage my model code recently, and it starts to shine in my toolbox…

1. Initialization

git init

This will create a .git directory in the current folder.

2. Basic config

git config --global user.name <user_name>
git config --global user.email <user_email>

Or we could use the following command to edit the global setting:

git config --global -e

3. Add files to the repository

git add <file_name>

4. Commit the changes to the repository

git commit -m <message>

5. Clone the repository from elsewhere

git clone <source_link> <new name>

6. Find the difference

git diff     #This would find the difference between cache and work files

git diff --cache   #This would find the difference between repository and cache

git diff HEAD    #This would find the difference between repository and work files

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s