1. 程式人生 > >GIT命令自學(主要給自己看)

GIT命令自學(主要給自己看)

首先從GIT官網(https://git-scm.com/)下載程式安裝。

推薦一個GIT教程網站:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

檢視版本:

$ git --version
git version 2.15.1.windows.2

克隆:

$ git clone [email protected]:***********/mmall.git
Cloning into 'mmall'...
remote: Counting objects: 86, done.
remote: Compressing objects: 100% (75/75), done.
remote: Total 86 (delta 38), reused 0 (delta 0)
Receiving objects: 100% (86/86), 22.92 KiB | 45.00 KiB/s, done.
Resolving deltas: 100% (38/38), done.

下面是碼雲(https://gitee.com/)新增公鑰的方法:

[email protected] MINGW64 ~/Desktop
$ ssh-keygen -t rsa -C "*********@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
/c/Users/Administrator/.ssh/id_rsa already exists.
Overwrite (y/n)?

[email protected]
MINGW64 ~/Desktop $ cat ~/.ssh/id_rsa.pub ssh-rsa ****B3NzaC1yc2EAAAADAQABAAABAQDhldtejt7jxX0PsiacX3+MKzH0JBMm6k5ro4t27bGkQfrBmc6ICNGUdE6vtw5Itq1KKNi2****HNhDfkr+S79cPmmTakh0DpH7cxmb+QEF759z/JNNfd+VHLe23O1VjljD0LVnrfHNVfUjXZLozVhru4iUPAWIsDQ2AERZI3/In5mKDhJwN/jElhf8DwGIuZ4GZ+sjovvClBJQAvE+X8MVfR/NRsqa1rq2MHhBCY5ul3rKTYtzOxIFvEgaN3Rl8zsB1jhf7xuLFyHHEfaB+qyponeipWCh0lcFreiDxswaT1NOALir3agESYBspK8xC9ZmwEOWkcFyOvBEzklO3yDn *********@qq.com
[email protected]
MINGW64 ~/Desktop $ ssh -T [email protected] Welcome to Gitee.com, **!

檢視遠端分支

$ git branch -r
  origin/HEAD -> origin/master
  origin/master
  origin/v1.0

Git初始化

[email protected] MINGW64 /e/git
$ mkdir test

[email protected] MINGW64 /e/git
$ cd test

[email protected] MINGW64 /e/git/test
$ touch .gitignore

[email protected] MINGW64 /e/git/test
$ touch README.md

[email protected] MINGW64 /e/git/test
$ git init
Initialized empty Git repository in E:/git/test/.git/

Git Commit

[email protected] MINGW64 /e/git/test (master)
$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        .gitignore
        README.md

nothing added to commit but untracked files present (use "git add" to track)

[email protected] MINGW64 /e/git/test (master)
$ git add .

[email protected] MINGW64 /e/git/test (master)
$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   .gitignore
        new file:   README.md


[email protected] MINGW64 /e/git/test (master)
$ git commit -am 'first'
[master (root-commit) cd20c72] first
 2 files changed, 1 insertion(+)
 create mode 100644 .gitignore
 create mode 100644 README.md

這個時候還沒有遠端倉庫,現在增加遠端倉庫。

[email protected] MINGW64 /e/git/test (master)
$ git remote add origin [email protected]:***********/test.git


Git push

[email protected] MINGW64 /e/git/test (master)
$ git branch
* master

[email protected] MINGW64 /e/git/test (master)
$ git branch -r

[email protected] MINGW64 /e/git/test (master)
$ git push -u origin master
To gitee.com:lhchanghong/test.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to '[email protected]:lhchanghong/test.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

[email protected] MINGW64 /e/git/test (master)
$ git pull
warning: no common commits
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From gitee.com:lhchanghong/test
 * [new branch]      master     -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master


[email protected] MINGW64 /e/git/test (master)
$ git push -u -f origin master
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 253 bytes | 253.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0)
To gitee.com:lhchanghong/test.git
 + c085cdc...cd20c72 master -> master (forced update)
Branch 'master' set up to track remote branch 'master' from 'origin'.


Git 增加分支

[email protected] MINGW64 /e/git/test (master)
$ git checkout -b my origin/master
Switched to a new branch 'my'
Branch 'my' set up to track remote branch 'master' from 'origin'.

[email protected] MINGW64 /e/git/test (my)
$ git push origin HEAD -u
Total 0 (delta 0), reused 0 (delta 0)
To gitee.com:lhchanghong/test.git
 * [new branch]      HEAD -> my
Branch 'my' set up to track remote branch 'my' from 'origin'.

Git 切換分支

[email protected] MINGW64 /e/git/test (master)
$ git branch
* master
  my

[email protected] MINGW64 /e/git/test (master)
$ git checkout my
Switched to branch 'my'
Your branch is up to date with 'origin/my'.

Git 分支合併到master

[email protected] MINGW64 /e/git/test (my)
$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.

[email protected] MINGW64 /e/git/test (master)
$ git merge my
Updating cd20c72..87b402f
Fast-forward
 test.txt | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 test.txt

[email protected] MINGW64 /e/git/test (master)
$ git push
Warning: Permanently added the ECDSA host key for IP address '116.211.167.14' to the list of known hosts.
Total 0 (delta 0), reused 0 (delta 0)
To gitee.com:lhchanghong/test.git
   cd20c72..87b402f  master -> master

Git 撤銷add操作

$ git rm -r --cached .

Git撤銷對 檔案的修改

[email protected] MINGW64 /e/C#/ailink-mes-client (developer)
$ git checkout -- readme.txt

相關推薦

GIT命令自學主要自己

首先從GIT官網(https://git-scm.com/)下載程式安裝。 推薦一個GIT教程網站:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

構建自己計算機的知識體系,是自己進入編程學習的第一步自己的話

表單 網頁設計 數據結構 windows 體系 嘗試 感謝 使用 計算   我個人認為不管我去學習什麽新的東西,我肯定先去了解這個新事物的大體輪廓,需要知道的是:這個東西是圓的還是方的?是走的還是爬的?...然後嘗試尋找他的一些內在聯系。之後再選擇這個事物的一方面去深入了解

lombok使用自己的,只為不要忘記自己用過的技術

ref targe 添加 res tostring 當我 fin alsa nal 如何使用? 一、1)eclipse使用方法 1. 從項目首頁下載lombok.jar 2. 雙擊lombok.jar, 將其安裝到eclipse中(該項目需要jdk1.6+的環境)

爬取網易熱評做成網易雲熱門截圖形式自己的很亂有待更改

lac post 更改 with con requests true ext2 .post 1 import requests,json,os,datetime,math,re 2 from PIL import Image,ImageDraw,ImageFont

爬取網易熱評做成網易雲熱門截圖形式自己的很亂有待更改+

json roman reply 熱門 req fan sta strftime ram # coding: utf-8 import requests, json, os, time, math, re from PIL import Image, Image

自己-編寫測試用例的注意點之後想到還會更新

1.標題寫全之後,步驟不需要再從頭開始寫操作 反案例 正案例 2.每條內容不宜過多,若不可避免的內容過多時,應加序號用於區分 反案例 正案例 3.寫結果時注意是否與其他功能有互動 例:商品成功下單後商品詳情頁面所購商品規格的數量和商品列表頁面該商品的銷售量是否改變、我的訂單中是否

位,位元組,16進位制關係,以防忘記自己

1位元組=8位 一個16進製為0xf,一個16進位制數為四個二進位制數,0x0為0000,0xf為1111,即1個16進位制數為4位 UE軟體開啟bmp影象,如42 4D 38 04 04 00 00 00 00 00 36 04 00 00,每兩個16進位制數隔開,用意是

網路流建圖的幾點體會自己的筆記,持續更新

求大牛分享網路流題集與學習經驗,dp大牛要拍磚請去隔壁動態規劃筆記篇~~ 網路流建圖,實質是對實際問題的抽象。用一些圖論中的理論去模擬實際問題,然後再把解出的答案轉化為實際問題的答案。 限制通常體現在邊權上,實際意義什麼的可能體現在點上也可能體現在邊上。 網路流適用問題一:

C# 學習之接口自己,沒有權威,歡迎糾正

教程 pub oid 沒有 命名 自己 特性 face 但是 重新學習了C#的三大特性,發現接口一直沒有使用,都快忘了,廢話不說,這裏沒有代碼,主要是描述給我自己看的(主要是網上的教程都是W3的,沒有什麽口語化的描述) 1、 接口是需要實例的,在使用的時候一定要實例  

痞子衡嵌入式:極精簡的Git命令教程1- 準備(init/config/.gitignore)

rec 精簡 gpo 課程 根據 信息 -- 文件中 嵌入式   今天是Git系列課程第一課,痞子衡給大家要講的是創建repo的準備工作。 1.建倉庫git init   第一步是創建一個空repo,這是一切操作的前提。 # 打開git bash命令行,切換到指定目錄下

痞子衡嵌入式:極精簡的Git命令教程2- 連接(remote/clone)

我們 pair ssh key 技術 彈出 change 能夠 sha2 permanent   今天是Git系列課程第二課,上一課我們已經學會在本地創建一個空repo,痞子衡今天要講的是如何將本地倉庫與遠程建立聯系。 1.將本地倉庫掛上遠程git remote   本地

痞子衡嵌入式:第一本Git命令教程3- 編輯(status/add/rm/mv)

this 通知 一次 ranch card use div 添加文件 app   今天是Git系列課程第三課,前兩課我們都是在做Git倉庫準備工作,今天痞子衡要講的是Git本地提交前的準備工作。   本地有了倉庫,我們便可以在倉庫所在目錄下做文件增刪改操作,這些操作默認都

痞子衡嵌入式:第一本Git命令教程5- 提交(commit/format-patch/am)

今天 分布 控制系統 rom end stat 準備工作 多少 cond   今天是Git系列課程第五課,上一課我們做了Git本地提交前的準備工作,今天痞子衡要講的是Git本地提交操作。   當我們在倉庫工作區下完成了文件增刪改操作之後,並且使用git add將文件改動記

git命令2

git 命令行一、父提交的表示方法 1.HEAD引用 在.git/HEAD目錄下存在一個HEAD文件,其記錄著當前工作區對應的SHA1。如果當前工作區從某個分支檢出(checkout),那麽這個HEAD文件中的引用最終執行分支對應的SHA1,如果處於分離頭狀態(不對應分支,從某個commit檢查),那麽這個H

git命令3之遠程版本庫

git一、遠程版本庫相關概念 1.裸版本庫和開發版本庫 裸版本庫就是不含有工作區的版本庫,而我們平常開發的代碼庫都是開發版本庫,修改工作區,然後進行提交、推送提交等操作。可以使用git init --bare命令創建一個裸版本庫。裸版本庫一般作為服務器上的版本庫。 2.refspec 引用空間把遠程分支版本庫

git命令4其他

git一.忽略文件 1.文件分類 git將所有文件分成三類:已追蹤的、被忽略的以及未追蹤的。 已追蹤的:表示已經存在版本庫中的,或者以暫存到暫存區的 被忽略的:在忽略文件中配置的忽略文件 位追蹤的:出去上面的兩類,例如新增的工作區的文件 2. gitignore文件 可以在gitignore中配置忽略文件

git 命令

IT 暫存區 round 不同版本 版本控制 p s OS ref 修改 1. 版本回退 在實際工作中,我們腦子裏怎麽可能記得一個幾千行的文件每次都改了什麽內容,不然要版本控制系統幹什麽。版本控制系統肯定有某個命令可以告訴我們歷史記錄,在Git中,我們用 git log

git 命令-推送分支到遠程

clas code match lin line 一個 lob 命令 default 在本地新建一個分支: git branch newBranch 切換到你的新分支: git checkout newBranch 創建並切換到新分支: git checkout -b

git 命令大全完整版

拉取 str 修改版本 xxx 用戶 command 克隆 單個 sage Git 常用命令詳解 Git 是一個很強大的分布式版本控制系統。它不但適用於管理大型開源軟件的源代碼,管理私人的文檔和源代碼也有很多優勢。 1.Git文件操作 $ git help [command

git命令使用

上次寫的git命令,基本上能夠支援一個專案的基本運行了,但是git不是就那幾個命令還有一些其他的命令,來看一下 建立一個資料夾,想在這個資料夾下建立專案,就執行這個命令就行 $ git init   裡面有一些配置啥的選項,我是基本上不去配置這些,一路的回車操作,建立完成,資料夾下會出現p