拓展閱讀
Subversion 開源的版本控制系統(tǒng)入門介紹 VCS
Git 開源的版本控制系統(tǒng)-01-入門使用介紹
Git 開源的版本控制系統(tǒng)-02-base usage 基本用法
Git 開源的版本控制系統(tǒng)-03-時間數(shù)據(jù)回溯
Git 開源的版本控制系統(tǒng)-04-branch manage 分支管理
Git 開源的版本控制系統(tǒng)-05-tags 標(biāo)簽管理
Git 開源的版本控制系統(tǒng)-06-share to github 如何把項(xiàng)目代碼共享到 github
Git 開源的版本控制系統(tǒng)-07-gitignore 指定忽略版本管理的文件
Base usage 基本用法
git status
顯示 Git 文件的狀態(tài);
這條命令用于查看工作目錄和暫存區(qū)的狀態(tài)。它會列出哪些文件已經(jīng)被修改、哪些文件被添加到暫存區(qū)、哪些文件尚未被跟蹤等。
這有助于你了解當(dāng)前倉庫的狀態(tài),從而決定下一步的操作,比如提交更改或撤銷更改。
$ git status
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
pom.xml
nothing added to commit but untracked files present (use "git add" to track)
git add
將文件添加到本地倉庫的暫存區(qū)。
$ git add .gitignore
上面的命令將 .gitignore
文件添加到暫存區(qū),準(zhǔn)備進(jìn)行提交。
git commit
將暫存區(qū)的文件提交到本地倉庫的歷史記錄中。
在使用 git commit
命令時,通常會附加一條消息來描述此次提交的更改內(nèi)容,這有助于其他開發(fā)者理解你所做的更改。
$ git commit -m "Add .gitignore file to ignore unnecessary files"
上面的命令將暫存區(qū)中的文件提交到本地倉庫,并附加了一條消息說明此次提交的內(nèi)容是添加了 .gitignore
文件以忽略不必要的文件。
$ git commit -m "first commit"
[master (root-commit) 965cf5d] first commit
1 file changed, 6 insertions(+)
create mode 100644 .gitignore
git push
將文件推送到遠(yuǎn)程倉庫
$ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
$ git push --set-upstream origin master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 258 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/houbb/git-demo.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
這樣,我們可以將另一個文件README.md
添加到倉庫中進(jìn)行測試,內(nèi)容為:
> Hello Git
現(xiàn)在,我們將文件README.md
編輯為以下內(nèi)容:
> Hello Git
- git diff
git diff
查看本地與倉庫之間的差異
$ git diff README.md
diff --git a/README.md b/README.md
index adb219f..e5a680e 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,2 @@
-> Hello Git
\ No newline at end of file
git log
顯示 git 的提交記錄日志
$ git log
commit cd84e273e5ac1d42d08090d013696a237b120751
Author: houbinbin <1060732496@qq.com>
Date: Mon Oct 10 18:43:33 2016 +0800
git diff
commit 9f18a0cd10ac0eb661ab1a9bf056398c5e6fe6f3
Author: houbinbin <1060732496@qq.com>
Date: Mon Oct 10 18:14:38 2016 +0800
add readme
cd84e273e5ac1d42d08090d013696a237b120751
是 commit_id
,即提交的唯一標(biāo)識符。文章來源:http://www.zghlxwxcb.cn/news/detail-837903.html
本文由博客一文多發(fā)平臺 OpenWrite 發(fā)布!文章來源地址http://www.zghlxwxcb.cn/news/detail-837903.html
到了這里,關(guān)于Git 開源的版本控制系統(tǒng)-02-base usage 基本用法的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!