安裝Git版本控制系統 以及Git Bash的基礎命令


Git是一個開源的分布式版本控制系統,用於敏捷高效地處理任何或小或大的項目。Git 是 Linus Torvalds 為了幫助管理 Linux 內核開發而開發的一個開放源碼的版本控制軟件。

1.官網下載。網址為:https://git-scm.com/download。截圖如下所示。點擊“Downloads for Windows”按鈕,便可跳轉到下載鏈接,完成下載。

2.點擊之后進入下載頁面,下載最新版本后有了這個文件夾然后雙擊

3.接下來進行安裝,選安裝地址

可勾選:On the Desktop,這樣,會自動在桌面生成Git的快捷方式。

可不勾選:Git GUI Here。目前,我都是使用Git Bash來進行操作。使用Git GUI,確實可以得到更好的UI體驗,不過,個人認為會減低效率。並且,初學者,還是先搞懂Git的常用指令,之后,再使用Git GUI才會有更好的理解。

4.安裝Git完成之后,會在桌面創建Git Bash快捷方式,在任意目錄下右擊鼠標可以找打Git Bash Here的選項。打開Git客戶端界面,輸入git。

或者在Windows里面輸入Git點擊Git-bash進入命令界面彈框

5.命令彈框

lenovo@LAPTOP-LG72BB3R MINGW64 /
$ git
usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone      Clone a repository into a new directory
   init       Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add        Add file contents to the index
   mv         Move or rename a file, a directory, or a symlink
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
   bisect     Use binary search to find the commit that introduced a bug
   grep       Print lines matching a pattern
   log        Show commit logs
   show       Show various types of objects
   status     Show the working tree status

grow, mark and tweak your common history
   branch     List, create, or delete branches
   checkout   Switch branches or restore working tree files
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   merge      Join two or more development histories together
   rebase     Reapply commits on top of another base tip
   tag        Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch      Download objects and refs from another repository
   pull       Fetch from and integrate with another repository or a local branch
   push       Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.

lenovo@LAPTOP-LG72BB3R MINGW64 /
$ pwd
/

lenovo@LAPTOP-LG72BB3R MINGW64 /
$ ls
bin/  cmd/  dev/  etc/  git-bash.exe*  git-cmd.exe*  LICENSE.txt  mingw64/  proc/  ReleaseNotes.html  tmp/  unins000.dat  unins000.exe*  unins000.msg  usr/

lenovo@LAPTOP-LG72BB3R MINGW64 /
$



6.然后就可以開始用Git了,,,基礎知識
Git bash 下操作文件及文件夾命令

1, cd : change directory的簡寫,改變目錄的意思,就是切換到哪個目錄下, 如 cd e:\fff  切換 E 盤下面的fff 目錄。

  當我們用cd 進入文件夾時,我們可以使用 通配符*, cd f*,  如果E盤下只有一個f開頭的文件夾,它就會進入到這個文件夾.

2, cd .. 回退到上一個目錄。我們在寫js,或css時,我們引入文件時,.. 表示的就是上一個目錄, 所以 cd .. 回退到上一個目錄就很好理解了。注意,cd 和兩個點點..之間有一個空格,  

3, pwd : print working directory, 打印工作目錄,它會顯示我們當前所在的目錄路徑。

4, ls: list, 列出當前目錄中的所有文件,     只不過ll(兩個ll)列出的內容更為詳細。

5, touch : 新建一個文件 如 touch index.js 就會在當前目錄下新建一個index.js文件。

6,rm:  remove,刪除一個文件, rm index.js 就會把index.js文件刪除.

7,  mkdir: make directory 新建一個目錄,就是新建一個文件夾. 如mkdir src 新建src 文件夾.

8,  rm -r :  刪除一個文件夾, r (recusive 是遞歸的意思), 刪除用的就是遞歸,先刪除文件夾里面的內容,再刪除文件夾。 rm -r src 刪除src目錄。 

9,  mv 移動文件, mv index.html src   index.html 是我們要移動的文件, src 是目標文件夾,當然, 這樣寫,必須保證文件和目標文件夾在同一目錄下.

10, reset 清屏,把git bash命令窗口中的所有內容清空。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM