Git入門基礎命令
git init:初始化一個repository。
例項:
[email protected] MINGW64 ~/2333
$ git init
Initialized empty Git repository in C:/Users/lewis/2333/.git/
git clone: 從網路clone到本地。
例項:
[email protected] MINGW64 ~ $ git clone https://github.com/udacity/asteroids.git Cloning into 'asteroids'... remote: Counting objects: 209, done. remote: Total 209 (delta 0), reused 0 (delta 0), pack-reused 209 Receiving objects: 100% (209/209), 199.25 KiB | 25.00 KiB/s, done. Resolving deltas: 100% (126/126), done.
git log: 顯示詳細的每次commit的日誌。
例項:
$ git log
commit b0678b161fcf74467ed3a63110557e3d6229cfa6
Author: cbuckey <[email protected]>
Date: Mon May 24 04:15:21 2010 -0700
Revert controls
commit f19cb1b80fe27e938e4d72770ca0a42f25e99ecc
Author: cbuckey <[email protected]>
Date: Mon May 24 04:03:05 2010 -0700
Fix typo in space
commit 75928a98e18479b22b18888a33d36379f17b43c1
Author: cbuckey < [email protected]>
Date: Mon May 24 03:54:42 2010 -0700
Use space for movement and enter for shooting
commit ac83b72030d79cf35944125793efcbdf57d93635
Author: Doug McInnes <[email protected]>
Date: Sun May 23 00:01:21 2010 -0700
mostly finished ipad version
git diff :
查詢2個commit的id之間的詳細差異,比如刪去,添加了哪些程式碼。
例項:
[email protected] MINGW64 ~/asteroids (master)
$ git diff 4035769377cce96a88d5c1167079e12f30492391 25ede836903881848fea811df5b6 87b59d962da3
diff --git a/game.js b/game.js
index 7595a9d..5daadb0 100644
--- a/game.js
+++ b/game.js
@@ -1167,8 +1167,7 @@ $(function () {
}
};
- var frameInterval = 25;
- var mainLoopId = setInterval(mainLoop, frameInterval);
+ var mainLoopId = setInterval(mainLoop, 25);
$(window).keydown(function (e) {
switch (KEY_CODES[e.keyCode]) {
@@ -1182,7 +1181,7 @@ $(function () {
Text.renderText('PAUSED', 72, Game.canvasWidth/2 - 160, 120);
} else {
lastFrame = Date.now();
- mainLoopId = setInterval(mainLoop, frameInterval);
+ mainLoopId = setInterval(mainLoop, 10);
}
break;
case 'm': // mute
:...skipping...
diff --git a/game.js b/game.js
index 7595a9d..5daadb0 100644
--- a/game.js
+++ b/game.js
@@ -1167,8 +1167,7 @@ $(function () {
}
};
- var frameInterval = 25;
- var mainLoopId = setInterval(mainLoop, frameInterval);
+ var mainLoopId = setInterval(mainLoop, 25);
$(window).keydown(function (e) {
switch (KEY_CODES[e.keyCode]) {
@@ -1182,7 +1181,7 @@ $(function () {
Text.renderText('PAUSED', 72, Game.canvasWidth/2 - 160, 120);
} else {
lastFrame = Date.now();
- mainLoopId = setInterval(mainLoop, frameInterval);
+ mainLoopId = setInterval(mainLoop, 10);
}
break;
case 'm': // mute
git checkout:切換到具體commit的id的分支。
例項:
[email protected] MINGW64 ~/asteroids (master)
$ git checkout 25ede836903881848fea811df5b687b59d962da3
Note: checking out '25ede836903881848fea811df5b687b59d962da3'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at 25ede83... a couple missing ends with the ipad version
git status:查詢 repository的狀態。
例項:
[email protected] MINGW64 ~/asteroids ((25ede83...))
$ git status
HEAD detached at 25ede83
nothing to commit, working tree clean
git add:新增檔案到暫存區
例項:
[email protected] MINGW64 ~/bilibili_spider/reflections (master)
$ git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: lesson_2_reflections.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
reflection.txt
[email protected] MINGW64 ~/bilibili_spider/reflections (master)
$ git add reflection.txt
[email protected] MINGW64 ~/bilibili_spider/reflections (master)
$ git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: lesson_2_reflections.txt
new file: reflection.txt
[email protected] MINGW64 ~/bilibili_spider/reflections (master)
$
git commit :提交暫存區的檔案到git
示例:
[email protected] MINGW64 ~/bilibili_spider (master)
$ git commit
[master (root-commit) 85b0105] test commit
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 reflections/lesson_2_reflections.txt
create mode 100644 reflections/reflection.txt
[email protected] MINGW64 ~/bilibili_spider (master)
$ git status
On branch master
nothing to commit, working tree clean
[email protected] MINGW64 ~/bilibili_spider (master)
$ git log
commit 85b0105896b8e8daa31b5f381e14832c60adeeed
Author: qq1367212627 <[email protected]>
Date: Tue Nov 15 10:59:07 2016 +0800
test commit
2016/11/15
Powered By Lewis
[email protected] MINGW64 ~/bilibili_spider (master)
git diff與git diff --staged比較圖:
以下命令先維護了2個檔案,提交game.js到暫存區(staging area),分別與工作區(working direction)和存庫區(repository)比較,最後使用git reset --hard清除staging area。
[email protected] MINGW64 ~/asteroids (master)
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: game.js
modified: index.html
no changes added to commit (use "git add" and/or "git commit -a")
[email protected] MINGW64 ~/asteroids (master)
$ git didd
git: 'didd' is not a git command. See 'git --help'.
Did you mean this?
diff
[email protected] MINGW64 ~/asteroids (master)
$ git diff
diff --git a/game.js b/game.js
index 49bf5ea..8809e58 100644
--- a/game.js
+++ b/game.js
@@ -421,6 +421,7 @@ Ship = function () {
}
if (KEY_STATUS.space) {
if (this.delayBeforeBullet <= 0) {
+ this.delayBeforeBullet = 10;
for (var i = 0; i < this.bullets.length; i++) {
if (!this.bullets[i].visible) {
SFX.laser();
diff --git a/index.html b/index.html
index 8aa618d..ac21916 100644
--- a/index.html
+++ b/index.html
@@ -23,8 +23,7 @@
<div id="left" class='button'>LEFT</div>
<div id="right" class='button'>RIGHT</div>
</div>
- <div id="right-controls">
- <div id="space" class='button'>FIRE</div>
+ <div id="right-controls"><div id="space" class='button'>FIRE</div>
</div>
</div>
</body>
[email protected] MINGW64 ~/asteroids (master)
$ git add game.js
[email protected] MINGW64 ~/asteroids (master)
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: game.js
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: index.html
[email protected] MINGW64 ~/asteroids (master)
$ git --staged
Unknown option: --staged
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>]
[email protected] MINGW64 ~/asteroids (master)
$ git diff --staged
diff --git a/game.js b/game.js
index 49bf5ea..8809e58 100644
--- a/game.js
+++ b/game.js
@@ -421,6 +421,7 @@ Ship = function () {
}
if (KEY_STATUS.space) {
if (this.delayBeforeBullet <= 0) {
+ this.delayBeforeBullet = 10;
for (var i = 0; i < this.bullets.length; i++) {
if (!this.bullets[i].visible) {
SFX.laser();
[email protected] MINGW64 ~/asteroids (master)
$ git commit
[master 8fc4917] fix bug
1 file changed, 1 insertion(+)
[email protected] MINGW64 ~/asteroids (master)
$ git diff
diff --git a/index.html b/index.html
index 8aa618d..ac21916 100644
--- a/index.html
+++ b/index.html
@@ -23,8 +23,7 @@
<div id="left" class='button'>LEFT</div>
<div id="right" class='button'>RIGHT</div>
</div>
- <div id="right-controls">
- <div id="space" class='button'>FIRE</div>
+ <div id="right-controls"><div id="space" class='button'>FIRE</div>
</div>
</div>
</body>
[email protected] MINGW64 ~/asteroids (master)
$ git diff --staged
[email protected] MINGW64 ~/asteroids (master)
$ git reset --hard
HEAD is now at 8fc4917 fix bug
[email protected] MINGW64 ~/asteroids (master)
$ git diff
[email protected] MINGW64 ~/asteroids (master)
$ git reset --hard
HEAD is now at 8fc4917 fix bug
[email protected] MINGW64 ~/asteroids (master)
$ git diff --staged
[email protected] MINGW64 ~/asteroids (master)
$ git log
commit 8fc49178ebbe70f57df54a89919ca01efb38ebac
Author: qq1367212627 <[email protected]>
Date: Tue Nov 15 11:41:24 2016 +0800
fix bug
Powered By Lewis
2016/11/15
git branch:查詢/建立新的分支(git branch 分支名)
以下建立了一個名為:easy-mode的分支,並且將分支從master切換到easy-mode
[email protected] MINGW64 ~/asteroids (master)
$ git branch
* master
[email protected] MINGW64 ~/asteroids (master)
$ git branch easy-mode
[email protected] MINGW64 ~/asteroids (master)
$ git branch
easy-mode
* master
[email protected] MINGW64 ~/asteroids (master)
$ git checkout
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
[email protected] MINGW64 ~/asteroids (master)
$ git checkout easy-mode
Switched to branch 'easy-mode'
[email protected] MINGW64 ~/asteroids (easy-mode)
$ git branch
* easy-mode
master
檔案合併策略示意圖:
git remote: 檢視遠端倉庫源
[email protected] MINGW64 ~/reflection (master)
$ git remote
origin
git remote -v:檢視遠端倉庫詳細地址
[email protected] MINGW64 ~/reflection (master)
$ git remote -v
origin https://github.com/qq1367212627/reflection.git (fetch)
origin https://github.com/qq1367212627/reflection.git (push)
git push:提交到github(遠端倉庫)上(向上更新)
[email protected] MINGW64 ~/reflection (master)
$ git push
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 284 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/qq1367212627/reflection.git
d6024ab..67b2b6b master -> master
git pull:從Github拉取commit,同步程式碼(向下更新)。
[email protected] MINGW64 ~/reflection (master)
$ git log
commit 3913ff943b35f42a645c77deb95c0c0006dc3a91
Author: qq1367212627 <[email protected]>
Date: Tue Nov 15 21:13:53 2016 +0800
commit 3
commit 67b2b6b412248367731c193aa0f6fed683b194f9
Author: qq1367212627 <[email protected]>
Date: Tue Nov 15 20:24:46 2016 +0800
測試
test
lewis
commit d6024ab8d0fe649d2e17db5b267b817ce1a78471
Author: qq1367212627 <[email protected]>
Date: Tue Nov 15 20:15:31 2016 +0800
Initial commit
[email protected] MINGW64 ~/reflection (master)
$ git pull
orremote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
ginremote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/qq1367212627/reflection
3913ff9..cd96efe master -> origin/master
Updating 3913ff9..cd96efe
Fast-forward
new_file.txt | 1 +
1 file changed, 1 insertion(+)
create mode 100644 new_file.txt
[email protected] MINGW64 ~/reflection (master)
$
[email protected] MINGW64 ~/reflection (master)
$ git log
commit cd96efe1c7046005463f69c1dc70b76a1bae11ec
Author: qq1367212627 <[email protected]>
Date: Tue Nov 15 21:20:36 2016 +0800
test pull
commit 3913ff943b35f42a645c77deb95c0c0006dc3a91
Author: qq1367212627 <[email protected]>
Date: Tue Nov 15 21:13:53 2016 +0800
commit 3
commit 67b2b6b412248367731c193aa0f6fed683b194f9
Author: qq1367212627 <[email protected]>
Date: Tue Nov 15 20:24:46 2016 +0800
測試
test
lewis
commit d6024ab8d0fe649d2e17db5b267b817ce1a78471
Author: qq1367212627 <[email protected]>
Date: Tue Nov 15 20:15:31 2016 +0800
Initial commit
git add -A :同步工作區與暫存區
git checkout .
#本地所有修改的。沒有的提交的,都返回到原來的狀態
git stash
#把所有沒有提交的修改暫存到stash裡面。可用git stash pop回覆。
git reset --hard HASH
#返回到某個節點,不保留修改。
git reset --soft HASH
#返回到某個節點。保留修改
git reset --hard HEAD~1 刪除上一次的commit
要新增一個新的遠端倉庫,可以指定一個簡單的名字,以便將來引用,執行 git
remote add [shortname] [url]
:
$ git remote
origin
$ git remote add pb git://github.com/paulboone/ticgit.git
$ git remote -v
origin git://github.com/schacon/ticgit.git
pb git://github.com/paulboone/ticgit.git
[email protected] MINGW64 ~/AndroidStudioProjects/HappyBirthDay (master)
$ git remote add pb https://github.com/qq1367212627/HappyBirthday.git
[email protected] MINGW64 ~/AndroidStudioProjects/HappyBirthDay (master)
$ git remote
pb
[email protected] MINGW64 ~/AndroidStudioProjects/HappyBirthDay (master)
$ git remote -v
pb https://github.com/qq1367212627/HappyBirthday.git (fetch)
pb https://github.com/qq1367212627/HappyBirthday.git (push)
相關推薦
Git入門基礎命令
git init:初始化一個repository。 例項: [email protected] MINGW64 ~/2333 $ git init Initialized empty Git repository in C:/Users/lewis/2333/
Git版本控制入門——基礎命令
首先需要安裝好Windows下的git 一、GitBash中配置 1.配置使用者資訊 配置使用者名稱你和郵箱 git如果和你的github使用者名稱和郵箱都完全一樣,則對本地倉庫修改再提交和直接對github倉庫修改是一樣的。 只要有一個不一樣,git本地倉庫提交到github是會認
Linux入門基礎命令(一)
linux運維Linux入門基礎命令內部命令常駐內存:由shell自帶的,而且通過某命令形式提供help:獲取所有內部命令列表(下圖只截取了一部分)enable COMMAND:執行此命令可以啟用COMMAND命令enable -n COMMAND:執行此命令可以禁用COMMAND命令enable -n:查看
linux入門——基礎命令
命令執行 watermark hash 控制 shadow mage size cto pro 一、命令概念 .終端(Terminal) ??命令是對Linux系統進行管理,LINUX系統用戶通過終端登錄的Shell進程,終端是Shell進程的控制終端。 ?? ??
Github中GIT BASH基礎命令列
GITHUB中GIT BASH基礎命令列 原文 : https://www.cnblogs.com/WangXinPeng/p/8016293.html 今天來講一下關於github命令列相關知識。呵呵,其實github都沒太明白就把git bash擺上來當道菜。看來,我有當程式設
Mysql入門基礎命令
turn like 0 rows shel ase fec start 1.10 count 一、Mysql基本操作 1.1 查詢當前數據庫 mysql> show databases; +--------------------+ | Database
Linux入門-基礎命令-mkdir-linux檔案與檔案管理
./ 當前目錄 …/ 上層目錄 mkdir -p 建立目錄所需要的遞迴目錄 例如在沒有test1目錄時,要建立/test1/test2的話,需要加-p; -m 設定目錄許可權,mkdir -p 711 /test1; **關於執行檔路徑檔案的變數:PATH∗∗
Linux前期入門基礎命令和簡單設置
type sytem 開機 圖形 tty 無法 鎖定 utf hash表 uid(用戶編號)id -u 查看當前用戶的用戶編號tty 查看當前登陸的是哪個終端alt + f1 返回原來的圖形界面 who 查看當前登陸終端的用戶,有IP地址的是遠程網絡連接終端的
Linux前期入門基礎命令和簡單設定
uid(使用者編號)id -u 檢視當前使用者的使用者編號tty 檢視當前登陸的是哪個終端alt + f1 返回原來的圖形介面 who 檢視當前登陸終端的使用者,有IP地址的是遠端網路連線終端的whoami 當前使用者名稱who am i 顯示的資訊比上面的那個更全w 誰在登陸,正在做什麼 顯示的資訊比前面
git入門基礎知識
一、git版本庫基礎知識 1.1 版本庫基礎知識 什麼是版本庫呢?版本庫又名倉庫,英文名repository,你可以簡單理解成一個目錄,這個目錄裡面的所有檔案都可以被Git管理起來,每個檔案的修改、刪除,Git都能跟蹤,以便任何時刻都可以追蹤歷史,或者在將來某個
docker入門 基礎命令 docker安裝
gin enc logout 最佳實踐 什麽 within 解決 加速 x86_64 在學一門新知識的時候,超哥喜歡提問,why?what?how? wiki資料 什麽是do
Git入門(安裝及基礎命令列操作)
一、安裝 1、Mac 在Mac中安裝Git的方法不止一種。最簡單的要數通過Xcode命令列工具。對於Mavericks(10.9)或更高版本的作業系統,當你第一次嘗試在終端執行git命令時,系統會自動檢查是否已安裝Git;如果未安裝,則會提示你安裝它。如果希望獲得更高的版本,也可以通過二進位制安裝程式
Git入門,基礎命令
Git 倉庫 ######sourceTree 一個 git 圖形介面管理工具####### 初始化版本庫 # git init ls -a 會多出一個 .git 新增檔案到版本庫 # git add 檔名 # git commit -m "描述資訊" 檢視倉
Git入門到高級系列1-git安裝與基礎命令
操作日誌 https aes key 菜單 apt-get system wrap ebp 視頻課程地址 騰訊課堂 為什麽要進行項目文件的版本管理 代碼備份和恢復 團隊開發和協作流程 項目分支管理和備份 git 是什麽? git是一個分布式的版本控制軟
git基礎命令。
所有 文件夾 遠程服務器 url add 服務器 遠程 nbsp comm 創建一個新的本地倉庫 git init 克隆遠程服務器 git clone URL 打開一個文件夾 cd 添加文件 git add . 本地提交更改 git commit
linux入門基礎知識及簡單命令介紹
linux基礎linux入門基礎知識介紹1、計算機硬件組成介紹計算機主要由cpu(運算器、控制器),內存,I/O,外部存儲等構成。 cpu主要是用來對二進制數據進行運算操作,它從內存中取出數據,然後進行相應的運算操作。不能從硬盤中直接取數據。 內存從外部存儲中取出數據供cpu運存。內存的最小單位是
Git基礎命令使用(個人總結)
down class 一次 onf set .net remote odin -a 個人在開發中整理常用的git命令,相信很多人會需要到的。 全局配置信息: git config --global user.name "Your name"
cmd 與 bash 基礎命令入門
切換目錄 目標 unix 文件中 交互式 例子 過去 bsp 參數 身為一個程序員會用命令行來進行一些簡單的操作,不是顯得很裝逼嘛!?嘿嘿~ ヾ(>?<) cmd 與 bash 基礎命令入門 ??????簡介 ??????CMD 基礎命令 ???????????
Linux發行版介紹、Linux系統基礎使用入門、Linux命令幫助、Linux基礎命令
系統運維 Linux 計算機打的基礎知識:CPU(運算器、控制器)、memory、I/O(輸入設備、輸出設備) 程序運行模式: 用戶空間:user space,us (可執行普通指令) 內核空間:system space (可執行特權指令) POS:Postable Operatin
git 基礎命令
local 方法 git push -m 刪除 直接 OS oca 分支 1、創建本地分支 local_branch git branch local_branch 2、創建本地分支local_branch 並切換到local_branch分支 git