1. 程式人生 > >GIT的理解和簡單操作

GIT的理解和簡單操作

smooth window state 右鍵 可視化 chan hat 文章 remember

輕量級的branch操作是git的一個根本特色。因為其他的版本管理工具是滿足一般的需要的。但是對branch的操作,由於缺乏實踐,暫時不深究。

GIT的操作一般是:
$ cd /home/user/my_project
$ git add *.c
$ git add LICENSE
$ git commit -m ‘initial project version‘
如果想要可視化的界面的支持的話,除了安裝官方的git外,還可以選擇性地安裝tortoiseGit。
這樣在Windows界面上就可以進行右鍵的可視化操作了。和操作SVN的感覺差不多。

其他:

-----------------

git commit -a

-a選項的解釋:

Tell the command to automatically stage files that have been modified and
deleted, but new files you have not told Git about are not affected.
這一個選項似乎可以把add命令也順便執行一下。
-----------------

The Three States
Pay attention now?—?here is the main thing to remember about Git if you want the
rest of your learning process to go smoothly. Git has three main states that your
files can reside in: committed, modified, and staged:

Committed means that the data is safely stored in your local database.
上句翻譯:已經commit的表示已經安全存入到本地的數據庫中了。
Modified means that you have changed the file but have not committed it to your
database yet.
上句翻譯:修改的就是已經修改,但是沒有進行任何git操作的。
Staged means that you have marked a modified file in its current version to go
into your next commit snapshot.
上句翻譯:操作為標記為已緩存。
-----------------
git add .
add命令把當前的snapshot更新到staging中。為以後的commit做準備。

參看資料:所有內容均可以在 https://git-scm.com/ 上查看到。並同時參考了其他人的cnblogs上的文章。

GIT的理解和簡單操作