GitGitHub語法大全

目錄

  • 1. GitHub與Git萬用語法
    • 1)創建庫
    • 2)添加和提交到倉庫
    • 3)版本回退
    • 4)緩存區和暫存區
    • 5)撤銷和刪除文件
    • 6)遠程倉庫
    • 7)創建和合并分支
  • 2. 更多Git語法

1. GitHub與Git萬用語法

1)創建庫

git init

2)添加和提交到倉庫

git add readme.txt                # 添加 
git status                        # 提交前查看狀態
git commit -m "description"       # 提交
git status                        # 提交后查看倉庫狀態
git diff readme.txt # 查看文件更改前后的內容變化

3)版本回退

# 現在->過去
git log                           # 查看歷史記錄  
git log --prettry=oneline         # 查看歷史記錄-簡易版
git reset --hard HEAD^            # 回退到上一個版本
git reset --hard HEAD~100         # 回退到第前10個版本# 過去->現在  
git reflog                        # 獲得所有提交命令的版本號  
git reset --hard <commit id>      # 通過版本號回到現在  

4)緩存區和暫存區

git add file1 file2 file3         # 添加到緩存區 
git commit -m "description"       # 一次性提交多個文件

5)撤銷和刪除文件

# 文件內容有誤,需要恢復到之前的版本:可以手動更改在commit,也可以回到HEAD^版本,本文介紹第三種方法
## version1:沒有加入到暫存區  
git status                        # 查看哪個文件被更改了
git checkout --filename           # 撤銷這個文件的更改 
## version2: 已經加入到暫存區  
git reset --hard HEAD^            # 先返回到上一版本(暫存區->工作區)
git checkout --filename           # 撤銷這個文件的更改
rm filename                       # 從工作區刪除filename  
git rm filename                   # 從版本庫刪除filename
git checkout -- filename          # 恢復刪除的filename

6)遠程倉庫

ssh-keygen -t rsa –C “youremail@example.com”    # 建立github和本地電腦的SSH Key鏈接  

本地->GitHub

git remote add origin git@server-name:path/repo-name.git  # 關聯一個GitHub
git push -u origin master          # 本地內容推送到GitHub(第一次用)
git push origin master             # 以后每次提交用

GitHub->本地

git clone git@github.com:haochen/learngit.git

7)創建和合并分支

git checkout -b feature1       # 創建并切換到feature1分支
git branch                     # 查看當前所有分支
git checkout master            # 切換到主分支  
git merge feature1             # 合并master和feature1分支:fast-mode模式
git merge --no-ff -m "merge with no-ff" <name>    #  合并分支,并且留下信息說明我在這里合并過 
git branch -d feature1         # 刪除feature1分支

解決合并沖突

git log --graph --pretty=oneline --abbrev-commit   # 樹狀圖查看分支情況

2. 更多Git語法

https://www.zhihu.com/question/38008771/answer/517332296

轉載于:https://www.cnblogs.com/haochen273/p/10214990.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/278519.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/278519.shtml
英文地址,請注明出處:http://en.pswp.cn/news/278519.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

從Firefox控制您喜歡的音樂播放器

Do you love listening to music while you browse? Now you can access and control your favorite music player directly from Firefox with the FoxyTunes extension. 您喜歡在瀏覽時聽音樂嗎&#xff1f; 現在&#xff0c;您可以直接使用FoxyTunes擴展程序從Firefox訪問和…

富文本編輯器初探

長期以來&#xff0c;作為用戶我是富文本編輯器的使用者&#xff0c;作為前端開發&#xff0c;我也只是富文本插件的使用者&#xff0c;對內部實現細節不甚了解&#xff0c;使用上也只停留在調用插件提供的API&#xff0c;實現一些業務邏輯。最近的項目&#xff0c;需要開發一個…

特殊的求和(函數和循環)

【問題描述】 編寫函數int fun(int a,int n)求Sn a aa aaa … aa…a 的值&#xff08;最后一個數中 a 的個數為 n &#xff09;&#xff0c;其中 a 是一個1~9的數字&#xff0c;例如&#xff1a;2 22 222 2222 22222 &#xff08;此時 a2 n5 &#xff09; 。參數由主函…

ms project 入門_Microsoft Project 2010入門

ms project 入門Would you like to keep your projects on track and keep track of how time and resources are used? Let’s take a look at Microsoft Project 2010 and how it can help you stay on top of your projects. 您想保持項目進度并了解如何使用時間和資源嗎&…

mysql基本的增刪改查和條件語句

增 insert into 表名&#xff08;列名,列名。。。。。。&#xff09; values("test1",23),("test2",23),("test3",24); 這條命令可以一次增加一條數據&#xff0c;也可以同時增加多條數據 還可以從插入其他的表到數據到當前表 insert into 插入的…

后端model傳入前端JSP頁面中的值判斷后再取值

所遇到的問題后端model傳入前端JSP頁面中的值通過foreach循環內要滿足條件才能取值給Div中&#xff0c;我們知道jsp頁面中可以直接用EL表達式取值&#xff0c;格式就是${"model中傳來的數據"},但是我要把傳過來的數據判斷后再取值就遇到了問題&#xff0c;通過查百度…

黑莓os軟件下載_在PC上試用BlackBerry OS

黑莓os軟件下載There’s a wider selection of smart phones and mobile OS’s than ever before, but you can’t just go buy every phone available and try them all out. Here’s how you can test out the latest version of the BlackBerry OS for free on your PC. 智…

IO流之轉換流

一 轉換流 1 OutputStreamWriter類 是字符流通向字節流的橋梁&#xff1a; 可使用指定的字符編碼表&#xff0c;將要寫入流中的字符編碼成字節。它的作用的就是&#xff0c;將字符串按照指定的編碼表轉成字節&#xff0c;在使用字節流將這些字節寫出去。 public static void m…

Spring事務管理(三)-PlatformmTransactionManager解析和事務傳播方式原理

2019獨角獸企業重金招聘Python工程師標準>>> Spring在事務管理時&#xff0c;對事務的處理做了極致的抽象&#xff0c;即PlatformTransactionManager。對事務的操作&#xff0c;簡單地來說&#xff0c;只有三步操作&#xff1a;獲取事務&#xff0c;提交事務&#x…

div方框彎曲邊樣式_使用彎曲樣式編輯文本

div方框彎曲邊樣式Would you like a new Notepad replacement that incorporates the latest technologies while staying slim and fast? Text editors are usually bland, boring programs, but here’s a new one that makes your text come to life beautifully. 您是否想…

分布式鎖的幾種實現原理

分布式鎖主流有三種模式&#xff1a; 實現方式 功能要求 實現難度 學習成本 運維成本 MySQL 的方案借助表鎖/行鎖實現 滿足基本要求 不難 熟悉 小量OK、大量影響現有業務、1主多從架構&#xff0c;不方便擴容 通過 ZK 創建數據節點的方式實現 滿足要求 熟悉 ZK API 即可 需要學…

如何破解您忘記的Windows密碼

Here at How-To Geek, we’ve covered many different ways to reset your password for Windows—but what if you can’t reset your password? Or what if you’re using drive encryption that would wipe out your files if you changed the password? It’s time to cr…

sql語句練習50題(Mysql版)

表名和字段–1.學生表Student(s_id,s_name,s_birth,s_sex) –學生編號,學生姓名, 出生年月,學生性別–2.課程表Course(c_id,c_name,t_id) – –課程編號, 課程名稱, 教師編號–3.教師表Teacher(t_id,t_name) –教師編號,教師姓名–4.成績表Score(s_id,c_id,s_score) –學生編號…

OpenCV3 識別圖中表格-JAVA 實現

2019獨角獸企業重金招聘Python工程師標準>>> 關于 JAVA 學習 OpenCV 的內容&#xff0c;函數講解。內容我均整理在 GitHubd的OpenCV3-Study-JAVA OpenCV 3 識別圖中表格-Java 實現 1. 說明 網上大部分資料&#xff0c;都是針對 C的&#xff0c;python、java 的例子太…

內存泄露 體現在哪個數字上_Microsoft剛剛泄漏了一個新的開始菜單。 你喜歡哪個?...

內存泄露 體現在哪個數字上NTAuthority on TwitterTwitter上的NTAuthorityMicrosoft messed up today, releasing an internal build of Windows 10 to Windows Insiders. This build was never meant to see the light of day, but it features a new Start menu design—with…

簡述 Spring Cloud 是什么

很多同學都了解了Spring &#xff0c;了解了 Spring Boot, 但對于 Spring Cloud 是什么還是比較懵逼的。 本文帶你簡單的了解下&#xff0c;什么是Spring Cloud。 Spring Cloud 是什么 從字面理解&#xff0c;Spring Cloud 就是致力于分布式系統、云服務的框架。 Spring Cloud …

js DOM節點

元素節點 4種方式獲取 var oDiv document.getElementById("box");        //通過Id獲取元素var oDiv document.getElementsByClassName("div")[0];   //通過類名獲取元素  --》[ 0 ] 必須寫var oDiv document.getElementsByTagName("…

python web scraping

2019獨角獸企業重金招聘Python工程師標準>>> 最近在看《Web Scraping with Python》&#xff0c;借此來熟悉Python2.7如何開始編程。 發現書上主要使用的 http://example.webscraping.com/ 網站有部分變化&#xff0c;書中的代碼有點無法對照使用&#xff0c;因此稍…

傅里葉變換的物理意義

用三角函數表示周期函數 傅里葉的相關理論始于下面假設&#xff1a;對于周期為1的信號$f(t)$&#xff0c;可以由不同頻率的三角函數組成&#xff0c; $f(t) \frac{a_0}{2}\displaystyle{\sum^{\infty}_{k1}}(a_kcos(2\pi kt)b_ksin(2\pi kt))$ 組成的基礎波形為一個信號對&…

天貓年度總結

2019獨角獸企業重金招聘Python工程師標準>>> 魯大師天貓工作總結 時間&#xff1a;2017年10月22日-1月30日 1、對代理商進行6大區域的劃分管理&#xff0c;有專門的客服指導。 2、加班費申請和車費報銷制度。 3、簡化了特權訂金2階段改成1階段&#xff0c;極大的方便…