git 基礎命令

2021-09-27 08:49:21 字數 1420 閱讀 8142

git init  初始化建立乙個倉庫

git clone  /path/to/repository  轉殖本地的乙個倉庫

git clone username@host:/path/to/repository  轉殖遠端伺服器上的倉庫

git add 把改動檔案新增到快取區

git add *  已有專案第一次使用git,把所有專案檔案都新增到git

git commit -m "**提交備註資訊"  把快取區的檔案提交到head。-m 選項以在命令列中提供提交注釋,沒有-m會直接彈出編輯器。-a直接跳過快取區,不用提前使用git add

git reset head  取消已快取的內容。

git status -s 檢視狀態

git branch (branchname)   建立新分支

git checkout (branchname)  切換分支

git  checkout -b (branchname)  建立新分支並且切換到該分支

git remote add [shortname] [url]   要新增乙個新的遠端倉庫,可以指定乙個簡單的名字,以便將來引用

ssh-keygen -t rsa -c "[email protected]"    建立ssh秘鑰

當為github時驗證是否成功,輸入以下命令:

$ ssh -t [email protected]

hi tianqixin! you've successfully authenticated, but github does not provide shell access.

git remote   檢視配置了哪些遠端倉庫

git remote -v   檢視配置的遠端倉庫的引數

git remove remote  刪除所有配置的遠端倉庫,

git remove remote (origin)刪除origin的遠端倉庫

git remote rm [別名]  刪除遠端倉庫

git merge  從遠端倉庫提取資料並嘗試合併到當前分支

git push [alias] [branch]    將你的 [branch] 分支推送成為 [alias] 遠端倉庫上的 [branch] 分支,例項如下。

git log  修改日誌,加引數--pretty=oneline單行顯示,--graph分支樹

git 重新定義.gitnore,使其生效

git rm -rf --cached .

git add .

git commit -m "refresh project git tree and index"

GIT 基礎 基礎命令

環境 centos7 yum install git這裡裡有個隱藏的資料夾 git 為git倉庫的配置資料夾,不可隨意修改 cd www git git init ls a git這裡和我們平時使用的git客戶端中設定使用者名稱和郵箱一樣的作用 git config global user.name...

Git 基礎命令

一 建立 git init 初始化乙個git倉庫 git add 把檔案新增到倉庫 git commit 把檔案提交到倉庫 二 顯示 git status 檢視倉庫當前的狀態 git log 檢視提交日誌 git reflog 檢視每次命令的記錄 三 管理 git reset hard head 把...

Git基礎命令

git現在廣泛應用在開發 管理中,想當年svn也是幹過這事,當然現在也還有人用,畢竟還是有情懷的嘛。對於測試,現在用git的還少,相對於檔案管理,svn還是會方便很多。當然,用習慣了git也方便,但是我第一次開始用吧,覺得特麻煩,把基礎命令總結下,免得幾日不用忘記。1.建立專案 不管是gitlab ...