免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
Git命令小記

Git命令小記

由于自己平常git用的不多不熟練,最近寫個小東西并把代碼托管到github,才發(fā)現(xiàn)之前看的《Pro Git》和《看日記學git》完全打水漂。重翻《Pro Git》,把一些重要的常見的命令記下來,備忘,具體的請man。

符號約定:

[]:可選  <>:必選

Git 配置

git config [--global] user.name <name>        設置用戶名

git config [--global] user.email <email>         設置郵箱

git config [--global] core.editor <editor>        設置編輯器

git config [--global] github.user <user>         設置github賬號名

git config [--global] github.token <token>        設置github的token

--global是對當前系統(tǒng)用戶的全局設置,在~/.gitconfig中。對系統(tǒng)所有用戶進行配置,/etc/gitconfig。對當前項目,.git/config

Git 創(chuàng)建庫

git clone <url>                   ssh/http(s)/git三種協(xié)議,ssh和https可推送

git init                        初始化Git倉庫

Git 日常操作

git add <file>                 將文件加入index file

git rm [--cached]                刪除,加--cached表示僅從index file中刪除文件,即放棄跟蹤

git mv <src> <dest>             移動/更名

git diff --cached/--staged          當前索引與上次提交(有哪些需要commit)

git diff                      當前索引與工作目錄(有哪些需要add)

git diff HEAD[^]               工作目錄與上次提交(當前目錄與上次提交有何改變)

git commit [-a] -m <msg>          提交

git commit --amend [-m <msg>]       修復上次提交

git reset HEAD <file>             同--mixed,default option

git reset --mixed HEAD            撤銷 commit 和index file,只保留 working tree 的信息

git reset --hard HEAD[^]           將 working tree 和 index file 都撤銷到以前狀態(tài)

git reset --soft HEAD[^]            只撤銷 commit,而保留 working tree 和 index file 的信息

                     回復到某個狀態(tài)。以git reset --soft HEAD為例,commit回退到

                     HEAD(相當于無變化),若是HEAD^,則commit回退到HEAD^

git gc                     用垃圾回收機制清除由于 reset 而造成的垃圾代碼

git status                  顯示當前工作目錄狀態(tài)

git log [-p]                   顯示提交歷史(many useful options to be learned)

git branch [branch]               顯示/新建分支

git branch -d/-D               刪除分支(d表示“在分支合并后刪除分支”,D表示無論如何都刪除分支)

git show-branch

git checkout <branch>            切換分支(分支未commit無法切換)

git merge <branch>              合并分支

git merge == git pull .

git show <branch | commit | tag | etc>        顯示對應對象的信息

git grep <rep> [object]             (在指定對象(歷史記錄)中)搜索        

git cat-file                    查看數(shù)據(jù)

git cat-file <-t | -s | -e | -p | (type)> <object>        type can be one of: blob, tree, commit, tag

git ls-files [--stage]              show information about files in the index and the working tree(實際是查看索引文件)

git watchchanged <since>..<until>       顯示兩個commit(當然也可以是branch)的區(qū)別

git remote [-v]                    顯示遠程倉庫,加-v選項可顯示倉庫地址

git remote add <repo_name> <url>         添加遠程倉庫,repo_name為shortname,指代倉庫地址

git remote rename <old_name> <new_name>    更名

git remote rm <repo_name>            刪除遠程倉庫

git remote show <repo_name>          查看遠程倉庫信息

git remote fetch <repo_name>           從遠程倉庫抓取數(shù)據(jù)(并不合并)

git pull <repo_name> <branch_name>      拉去數(shù)據(jù)并合并到當前分支

git push <repo_name> <branch_name>      推送指定分支到指定倉庫

git fetch <repo_name> <branch_name>[:<local_branch_name>]    拉去數(shù)據(jù),未合并

Git 標簽

git 標簽相關……

Git 相關環(huán)境變量

GIT_DIR: 如果指定了那么git init將會在GIT_DIR指定的目錄下創(chuàng)建版本庫

GIT_OBJECT_DIRECTORY: 用來指示對象存儲目錄的路徑。即原來$GIT_DIR/objects下的文件會置于該變量指定的路徑下

Git 常見變量

HEAD: 表示最近一次的 commit。

MERGE_HEAD: 如果是 merge 產(chǎn)生的 commit,那么它表示除 HEAD 之外的另一個父母分支。

FETCH_HEAD: 使用 git-fetch 獲得的 object 和 ref 的信息都存儲在這里,這些信息是為日后 git-merge 準備的。

HEAD^: 表示 HEAD 父母的信息

HEAD^^: 表示 HEAD 父母的父母的信息

HEAD~4: 表示 HEAD 上溯四代的信息

HEAD^1: 表示 HEAD 的第一個父母的信息

HEAD^2: 表示 HEAD 的第二個父母的信息

COMMIT_EDITMSG: 最后一次 commit 時的提交信息。


TO BE FINISHED!


本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Git常用命令總結(jié)
git 常用命令
真正理解 git fetch, git pull 以及 FETCH
github使用說明
git命令大全
GIT版本配置管理
更多類似文章 >>
生活服務
分享 收藏 導長圖 關注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服