git 命令集

git命令集 git命令基本使用。 阅读详情

git 命令集

分类: Linux 314人阅读 评论(0) 收藏 举报
 

git 命令集

 

-------------------------------------------------------------------------------

配置

-------------------------------------------------------------------------------

git config --global user.name "Karl Ma" 配置用户名

git config --global user.email karlcpp@gmail.com 配置用户mail

git config --global core.editor emacs 配置编辑器

git config --global merge.tool vimdiff  配置差异分析工具

git config --list 显示配置项

git config user.name 显示特定的配置项

以下是设置命令的别名

git config --global alias.co checkout

git config --global alias.br branch

git config --global alias.ci commit

git config --global alias.st status

 

-------------------------------------------------------------------------------

帮助

-------------------------------------------------------------------------------

git help

git help tag

git tag --help

 

-------------------------------------------------------------------------------

基本命令

-------------------------------------------------------------------------------

git init 要对现有的某个项目开始用 Git 管理,需到此项目所在的目录执行此命令

git init --bare --shared 在一个空目录下执行可以创建一个纯仓库, --shared 选项,Git 会自动对该仓库加入可写的组

git add *.c   跟踪新文件,将*.c的文件们增加到暂存区

gti commit 将暂存区的文件提交,会启动编辑工具

git commit -m 'some' 将暂存区的文件提交

git commit -a -m 'some' 自动把所有已经跟踪过的文件暂存起来一并提交,跳过git add步骤,没有跟踪的文件不会提交,也不增加

git commit --amend 重新提交,与上一次提交合并成一次提交

git clone git://github.com/schacon/grit.git 从远程服务器上clone一份,ssh协议的格式为user@server:/path.git

git clone git://github.com/schacon/grit.git mygrit 从远程服务器上clone一份到本地的mygrit目录

git clone file:///d:/myproject/test.git 本地协议clone

git clone /d/myprojects/test.git 本地协议lcone

git clone ssh://user@host:project.git 使用ssh协议

git clone user@host:project.git 同上,省略写法

git clone --bare my_project my_project.git 把一个仓库克隆为纯仓库

git status 检查当前文件状态

git add <file> 暂存已修改文件

git rm <file> 移除跟踪的文件,同时删除本地文件

git rm -f <file> 如果文件已经修改过并放到了暂存区,需要强制移除

git rm --cached <file> 不删除本地文件,只从跟踪清单中移除

git rm /*~  移除所有以~结尾的文件,从当前目前递归执行。/表示需要git来解释*而不是用shell来解释*,如果用shell来解决*的话,就不会有递归啦

git mv file_from file_to 移动文件,这里相当于改名,相当于执行了三条命令:(不论用哪种方式,git都会知道是改名啦)

$ mv README.txt README

$ git rm README.txt

$ git add README

git log 查看提交历史日志

git log -p 显示每次提交的差异

git log -p -2 只显示最近两次的提交日志,当然显示其差异

git log --stat 仅显示简要的增改行数统计

git log --pretty=oneline 每一个日志只显示在一行

git log --pretty=format:"%h - %an, %ar : %s" 以特定的格式显示

git log --graph 显示树形图

 

在项目目录下编辑.gitignore文件,忽略文件的模式

# 此为注释 – 将被 Git 忽略

*.a       # 忽略所有 .a 结尾的文件

!lib.a    # 但 lib.a 除外

/TODO     # 仅仅忽略项目根目录下的 TODO 文件,不包括 subdir/TODO

build/    # 忽略 build/ 目录下的所有文件

doc/*.txt # 会忽略 doc/notes.txt 但不包括 doc/server/arch.txt

 

git diff 比较工作目录中的文件与暂存区的文件的差异

git diff --cached 已经暂存起来的文件和上次提交时的快照之间的差异

git diff --staged 效果同上,1.6.1以上的git支持

 

gitk GUI界面

git reset HEAD benchmarks.rb 取消先前放到暂存区中的文件

git checkout -- benchmarks.rb 取消工作目录中文件的修改,恢复到修改前的版本

 

git remote 查看当前的远程库

git remote -v 查看当前的远程库,并显示对应的clone地址

git remote add pb git://github.com/paulboone/ticgit.git 添加一个远程库

git fetch pb 从远程仓库pb中抓取数据

git pull 从原始克隆的远端仓库中抓取数据后,合并到工作目录中当前分支

git push origin master 推送数据到远程仓库origin的master分支

git remote show origin 显示远程仓库origin的信息

git remote rename pb paul 将远程仓库pb重命名为paul

git remote rm paul 删除远程仓库paul

 

git tag 列显已有的标签

git tag -l 'v1.4.2.*' 列显以v1.4.2.开头标签

git tag -a v1.4 -m 'my version 1.4' 创建一个含附注类型的标签

git show v1.4 查看相应标签的版本信息,并连同显示打标签时的提交对象

git tag -s v1.5 -m 'my signed 1.5 tag' 签署标签

git tag -v v1.4.2.1 验证签署的标签

git tag v1.4-lw 轻量级标签

git tag -a v1.2 9fceb02 将校验和以9fceb02的一次提交打上v1.2的标签,需要先用git log --pretty=oneline命令看一下每次提交的校验和

git push origin v1.5 将v1.5的标签推送到远程仓库origin

git push origin --tags 将所有标签推送到远程仓库origin

 

-------------------------------------------------------------------------------

分支与合并

-------------------------------------------------------------------------------

git branch testing  创建一个testing分支

git checkout testing 将工作目录转换到testing分支上

git checkout -b testing 相当于上两条命令一起执行

 

git merge hotfix 将当前所在的分支(如master)合并到hotfix分支上,合并后hotfix和master会指向同一个快照

git branch -d hotfix  删除hotfix分支

git branch -D hotfix  强制删除hotfix分支,如果hotfix分支没有与当前分支合并过,用-d删除会返回错误,可以用-D强制删除

 

git status 可以查看哪些合并合并时发生了突出

 

git mergetool 调用一个可视化的合并工具,//在我的机器上会调用TortoiseMerge,我安装了TortoiseSVN

 

git add <file> 将修改完的(解决冲突的文件放到暂存区)

git commit -a -m 'some gugu' 直接将修改后的(解决了冲突的文件提交)

 

git branch 显示所有的分支,显示时前面有*那个分支为工作目录所在的分支

git branch -v 显示分支的同时,显示分支的最后一次信息

 

git branch --merged 查看哪些分支已被并入当前分支,删除这些分支(非当前分支不会损失什么)

git branch --no-merged 查看哪些分支没有并入当前分支,删除这些分支会损失

 

git push origin serverfix 取出我的 serverfix 本地分支,推送它来更新远程仓库origin的 serverfix 分支

git push origin myserverfix:serverfix 取出我的myserverfix 本地分支,推送它来更新远程仓库origin的 serverfix 分支

 

git merge origin/serverfix 如果要把origin仓库的serverfix内容合并到当前分支

 

git checkout -b serverfix origin/serverfix  从origin仓库的serverfix分支创建一个本地的serverfix分支

git checkout --track origin/serverfix 结果同上一条一样,1.6.2版本以上的git支持

 

git push [远程名] :[分支名] 删除一个远程分支

git push origin :serverfix 删除远程分支serverfix

 

git rebase master 将当前分支衍合到master分支

git rebase --onto master server client 相当于检出 client 分支,找出 client 分支和 server 分支的共同祖先之后的变化,然后把它们在 master 上重演一遍

git rebase master server 当前分支在master,这个命令相当于先转到server分支,再执行git rebase master

git常用命令大全 git常用命令大全,快速上手git,创建,删除,合并分支管理无压力。 立即下载

相关推荐

[AbutionGraph] 报表制作-使用Grafana动态可视化知识图谱指标

使用开源报表可视化工具Grafana实时监控时序知识图谱数据仓库AbutionGraph中的数据,实时性报表查询, 满足单次百万千万级的数据查询,毫秒级查询延迟,亚秒级对千亿数据量汇总统计,每日过亿报表查询/多维分析/日志分析等数据指标...

图特摩斯科技-博客 4278

史上最全的Git命令,收藏这这篇就够了

仓库 # 在当前目录新建一个Git代码库 $ git init # 新建一个目录,将其初始化为Git代码库 $ git init [project-name] # 下载一个项目和它的整个代码历史 $ git clone [url] 配置 # 显示当前的Git配置 $ git config --list # 编辑Git配置文件 $ git config -e [--globa...

HopperZheng的博客 1万+

Dinic算法的复杂度分析及证明

一般图 复杂度主要取决于dfs增广的过程。 将dfs部分的复杂度分成两部分来分析:1)修改增广路上边的流量。至多会增广mmm次,一条增广路的长度至多是nnn,所以这一部分的复杂度是O(nm)O(nm)O(nm)。2)dfs遍历时找增广路失败时经过的边。由于一旦从某条边出发找最短路失败了,我们就不会再走那条边(当前弧优化),所以这一部分的复杂度是O(m)O(m)O(m)的。故而dfs增广的复杂度是O...

这个博客已经搬到了:zhongyuwei.github.io 4392

常用git命令总结大全

一、常用命令 git init git add 文件名 git commit -m “备注” git status git diff git show commit_id 查看某次修改 git log或者git log —pretty=oneline或者git log —graph —pretty=oneline —abbrev-commit 用git log -...

wuhuagu_wuhuaguo的博客 5万+

【AutoDL】使用云服务器跑深度学习代码

1.算力市场 租用服务器,选择自己心仪的服务器2.镜像可以选择一些基础的镜像,社区镜像里是git上有的环境。3.上传文件在文件存储中,选择上传的区,在右边点击上传,选择自己的文件上传到云服务器中。

weixin_45768644的博客 3702

STM32双ADC同步采样实战:FFT测量相位差的5个关键细节

本文深入探讨了利用STM32双ADC同步采样结合FFT算法精确测量信号相位差的实战技巧。文章聚焦五个关键细节:确保ADC时钟同源、优化DMA缓冲区设计、信号调理与窗函数选择、精确的相位提取与解缠绕,以及系统误差校准与验证。这些细节是提升相位差测量精度、确保系统稳定性的核心,尤其强调了STM32配置中易被忽视的时钟同步问题。

oauth7security的博客 594

git常用的命令集

git 相关命令

weixin_45102459的博客 3037

基于百度地图API在AI Studio上的卫星地图块图像处理与分类

本项目基于百度地图API获取了不同的瓦片地图并进行合并等处理,可用于遥感和抽象地图的地图块的图像分类、分割、检测等数据的制作。瓦片地图金字塔模型是一种多分辨率层次模型,从瓦片金字塔的底层到顶层,分辨率越来越低,但表示的地理范围不变。首先确定地图服务平台所要提供的缩放级别的数量N,把缩放级别最高、地图比例尺最大的地图图片作为金字塔的底层,即第0层,并对其进行分块,从地图图片的左上角开始,从左至右、从上到下进行切割,分割成相同大小(比如256x256像素)的正方形地图瓦片,形成第0层瓦片矩阵;

斌擎科技 746

Git 命令大全(带详细说明)

本文是一份Git命令速查指南,涵盖了Git使用的核心场景和常用命令。主要内容包括:1)基础配置(用户信息、别名设置);2)仓库操作(初始化、克隆);3)文件管理(添加、提交、撤销);4)分支操作(创建、合并、删除);5)远程仓库管理;6)版本回退;7)标签管理;8)高级操作(rebase、cherry-pick);9)日常开发流程。指南采用"命令+说明"的简洁格式,包含常用参数和工作场景示例,适合开发者快速查阅Git操作。

qq_45712124的博客 6521

【AI智能体】Dify 搭建数据分析应用实战操作详解

Dify 搭建数据分析应用实战详解

congge 7296

【系统移植】 移植主线U-Boot(v2024.01-rc3)到RK3399

[系统移植] 移植主线U-Boot(v2024.01-rc3)到RK3399

Systemcall名屋 1004

Git常用命令大全

bin/sh# ~/bin/git-undo(需添加到PATH)# 使用:git undo # 回退上一个提交二十五、Git 工作流最佳实践。

m0_65848509的博客 9655

基于网关实现不同网段S7-1200 CPU的通信方法

在A网段的计算机上ping B网段的计算机:在A网段的计算机上使用ping命令,向B网段的计算机发送数据包。在B网段的计算机上ping A网段的计算机:同样地,在B网段的计算机上使用ping命令,向A网段的计算机发送数据包。数据包也会经过路由器进行转发,最终到达A网段的计算机。配置路由器:在路由器上配置两个网段的IP地址和子网掩码,并设置路由表,使得路由器可以将A网段和B网段之间的数据进行转发。确定两个网络之间的路由器:假设需要将A网段和B网段进行通信,需要在A、B两个网段之间设置一台路由器。

电工 2399

开发Git命令集

#!/usr/bin/env bash OLD_BASE=$(pwd) GIT_BASE=/mnt/mwadmin-tp/admin-model-curd cd $GIT_BASE git_status=$(git status) git_bot_need_commit="nothing to commit, working directory clean" if [[ $git_status == *$git_bot_need_commit* ]] then echo "$GIT_BAS.

TendaRouter的专栏 227

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Git命令集

##一. 项目创建 ###git init # 当前目录初始化仓库,添加.git文件夹 $ git init Reinitialized existing Git repository in /temp/.git/ ###git clone # 复制本地仓库,且不创建.git目录 $ git clone --bare git2/ git2Clone Cloning into bare repos...

qq_37073279的博客 211

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

git 基本命令集

1) 远程仓库相关命令 检出仓库:$ git clone git://github.com/xxx/jxx.git 查看远程仓库:$ git remote -v 添加远程仓库:$ git remote add [name] [url] 删除远程仓库:$ git remote rm [name] 修改远程仓库:$ git remote set-url --push[name][newUrl] 拉取远程仓库:$ git pull [remoteName] [localBranchName] 推送远程仓库:$ g

weixin_43564241的博客 277

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

上一篇: Git 常用命令
下一篇: Android Broadcast机制深入解析
Alex_csd
博客等级 码龄14年 1粉丝 2原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值