使用Git Bash for Windows

來源:互聯網
上載者:User

標籤:

 

本篇體驗Git Bash在Windows作業系統上的用法。

什麼是Bash?

是一個Shell環境,Bourne Again Shell的縮寫。

安裝git for windows

→ http://git-for-windows.github.io/
→ Download,選擇一個合適的版本
→ 安裝
→ 安裝完後有Git Bash, Git CMD, 和 Git GUI這個三個應用程式
→ 運行Git Bash,檢查目前的版本
git version
→ 退出
exit

安裝Notepad++

→ notepad-plus-plus.org
→ download,選擇合適的版本
→ 安裝

在Bash中開啟Notepad++

→ 找到notepad++的應用程式檔案
一般在C:\Program Files(x86)\Notepad++中,把C:\Program Files(x86)\Notepad++賦值
→ 右鍵"我的電腦",點擊"進階系統設定", 點擊"環境變數", 雙擊Path,把;C:\Program Files(x86)\Notepad++加到最後,點擊"確定"
→ 運行Git Bash
→ notepad++
這樣,在Bash中就開啟notepadd++了。

顯示查看目前的目錄

→ 運行Git Bash
→ 查看目前的目錄
pwd
顯示/c/Users/Darren,其中/c/相當於C:\,
→ 列出當前檔案夾下的所有檔案
ls

ls -l

更換目前的目錄

→ 運行Git Bash
→ 導航到其它目錄
cd Videos/
→ 退回到上一級
cd ..
→ 導航到My Documents目錄
cd My\ Documents/
→ 退回三級
cd ../../../
→ 回到主目錄
cd ~
→ 導航到一個絕對位置上的目錄
cd /c/Windows/System32/

查看命令出處

→ 查看ls命令的出處
whick ls
顯示/bin/ls

顯示列印

→ 顯示列印環境變數
echo $PATH

查看檔案內容

→ 查看一個檔案內容
cat test.txt
→ 查看一個檔案內容並編輯
less test.txt


建立、重新命名、移動、刪除檔案

→ 建立一個空檔案
touch demo.txt
→ 重新命名一個檔案
mv demo.txt demo-1.txt
→ 刪除已知檔案
rm demo-1.txt

建立、刪除目錄

→ 建立目錄
mkdir projects
→ 刪除目錄
rmdir projects
→ 建立多級目錄
mkdir projects/client-a/awesome-web-project/
→ 刪除多級目錄
rm -rf projects/

清空和退出

→ 清空內容
clear
→ 退出控制台
exit

控制台列印資訊輸出到檔案

→ 列印資訊輸出追加到建立檔案
echo "hi" >> demo.txt
→ 列印資訊輸入重寫已知檔案
echo "hello" > demo.txt

執行Bash指令碼

→ 查看bash安裝在哪裡
which bash
顯示:/bin/bash
→ 使用notepad++建立開啟一個檔案
notepad++ example.sh
→ 輸入命令

#!/bin/bash

echo "hi, everyone"




























使用Git Bash for Windows

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.