关于linuxgit命令的信息
linux怎么安装git 命令
一、使用包管理器安装GitGit已经被所有的主流Linux发行版所支持。所以安装它最简单的方法就是使用各个Linux发行版的包管理器。
创新互联公司主要从事成都网站设计、成都做网站、网页设计、企业做网站、公司建网站等业务。立足成都服务通州,10余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575
1、Debian, Ubuntu, 或 Linux Mint
1
$ sudo apt-get install git
2、Fedora, CentOS 或 RHEL
1
$ sudo yum install git或$ sudo dnf install git
3、Arch Linux
1
$ sudo pacman -S git
4、OpenSUSE
1
$ sudo zypper install git
5、Gentoo
1
$ emerge --ask --verbose dev-vcs/git
二、从源码安装Git
如果由于某些原因,希望从源码安装Git,按照如下介绍操作。
1、安装依赖包
在构建Git之前,先安装它的依赖包。
1
2
3
4
//Debian, Ubuntu 或 Linux Mint
$ sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev asciidoc xmlto docbook2x
//Fedora, CentOS 或 RHEL
$ sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc xmlto docbook2x
2、从github官网下载最新版本的Git。然后在/usr下构建和安装。
注意,如果打算安装到其他目录下(例如:/opt),那就把“--prefix=/usr”这个配置命令使用其他路径替换掉。
1
2
3
4
5
$ cd git-x.x.x
$ make configure
$ 。/configure --prefix=/usr
$ make all doc info
$ sudo make install install-doc install-html install-info
linux怎样命令行上传git
你是你是要通过git命令上传东西,还是想上传git到服务器上面,你可以先通过yum安装git
# yum install git
已加载插件:fastestmirror, refresh-packagekit, security
设置安装进程
Loading mirror speeds linuxprobe.com from cached hostfile
base | 3.7 kB 00:00
epel | 4.3 kB 00:00
epel/primary_db | 5.9 MB 00:05
extras | 3.4 kB 00:00
hhvm | 2.9 kB 00:00
shells_fish_release_2 | 1.2 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 821 kB 00:01
upgrade | 1.9 kB 00:00
virtualbox/signature | 181 B 00:00
virtualbox/signature | 1.1 kB 00:00 ...
包 git-1.7.1-8.el6.x86_64 已安装并且是最新版本
无须任何处理
#git --help
usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path]
[-p|--paginate|--no-pager] [--no-replace-objects]
[--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]
[--help] COMMAND [ARGS]
The most commonly used git commands are:
add Add file contents to the index
bisect Find by binary search the change that introduced a bug
branch List, create, or delete branches
checkout Checkout a branch or paths to the working tree
clone Clone a repository into a new directory
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
fetch Download objects and refs from another repository
grep Print lines matching a pattern
init Create an empty git repository or reinitialize an existing one
log Show commit logs
merge Join two or more development histories together
mv Move or rename a file, a directory, or a symlink
pull Fetch from and merge with another repository or a local branch
push Update remote refs along with associated objects
rebase Forward-port local commits to the updated upstream head
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
show Show various types of objects
status Show the working tree status
tag Create, list, delete or verify a tag object signed with GPG
See 'git help COMMAND' for more information on a specific command.
下面我给介绍一种从本地上传到服务器的命令:
命令rz和sz命令,首先你需要安装lrzsz库
#rz --help
rz version 0.12.20
Usage: rz [options] [filename.if.xmodem]
Receive files with ZMODEM/YMODEM/XMODEM protocol
(X) = option applies to XMODEM only
(Y) = option applies to YMODEM only
(Z) = option applies to ZMODEM only
-+, --append append to existing files
-a, --ascii ASCII transfer (change CR/LF to LF)
-b, --binary binary transfer
-B, --bufsize N buffer N bytes (N==auto: buffer whole file)
-c, --with-crc Use 16 bit CRC (X)
-C, --allow-remote-commands allow execution of remote commands (Z)
-D, --null write all received data to /dev/null
--delay-startup N sleep N seconds before doing anything
-e, --escape Escape control characters (Z)
-E, --rename rename any files already existing
--errors N generate CRC error every N bytes (debugging)
-h, --help Help, print this usage message
-m, --min-bps N stop transmission if BPS below N
-M, --min-bps-time N for at least N seconds (default: 120)
-O, --disable-timeouts disable timeout code, wait forever for data
--o-sync open output file(s) in synchronous write mode
-p, --protect protect existing files
-q, --quiet quiet, no progress reports
-r, --resume try to resume interrupted file transfer (Z)
-R, --restricted restricted, more secure mode
-s, --stop-at {HH:MM|+N} stop transmission at HH:MM or in N seconds
-S, --timesync request remote time (twice: set local time)
--syslog[=off] turn syslog on or off, if possible
-t, --timeout N set timeout to N tenths of a second
-u, --keep-uppercase keep upper case filenames
-U, --unrestrict disable restricted mode (if allowed to)
-v, --verbose be verbose, provide debugging information
-w, --windowsize N Window is N bytes (Z)
-X --xmodem use XMODEM protocol
-y, --overwrite Yes, clobber existing file if any
--ymodem use YMODEM protocol
-Z, --zmodem use ZMODEM protocol
short options use the same arguments as the long ones
#sz --help
sz version 0.12.20
Usage: sz [options] file ...
or: sz [options] -{c|i} COMMAND
Send file(s) with ZMODEM/YMODEM/XMODEM protocol
(X) = option applies to XMODEM only
(Y) = option applies to YMODEM only
(Z) = option applies to ZMODEM only
-+, --append append to existing destination file (Z)
-2, --twostop use 2 stop bits
-4, --try-4k go up to 4K blocksize
--start-4k start with 4K blocksize (doesn't try 8)
-8, --try-8k go up to 8K blocksize
--start-8k start with 8K blocksize
-a, --ascii ASCII transfer (change CR/LF to LF)
-b, --binary binary transfer
-B, --bufsize N buffer N bytes (N==auto: buffer whole file)
-c, --command COMMAND execute remote command COMMAND (Z)
-C, --command-tries N try N times to execute a command (Z)
-d, --dot-to-slash change '.' to '/' in pathnames (Y/Z)
--delay-startup N sleep N seconds before doing anything
-e, --escape escape all control characters (Z)
-E, --rename force receiver to rename files it already has
-f, --full-path send full pathname (Y/Z)
-i, --immediate-command CMD send remote CMD, return immediately (Z)
-h, --help print this usage message
-k, --1k send 1024 byte packets (X)
-L, --packetlen N limit subpacket length to N bytes (Z)
-l, --framelen N limit frame length to N bytes (l=L) (Z)
-m, --min-bps N stop transmission if BPS below N
-M, --min-bps-time N for at least N seconds (default: 120)
-n, --newer send file if source newer (Z)
-N, --newer-or-longer send file if source newer or longer (Z)
-o, --16-bit-crc use 16 bit CRC instead of 32 bit CRC (Z)
-O, --disable-timeouts disable timeout code, wait forever
-p, --protect protect existing destination file (Z)
-r, --resume resume interrupted file transfer (Z)
-R, --restricted restricted, more secure mode
-q, --quiet quiet (no progress reports)
-s, --stop-at {HH:MM|+N} stop transmission at HH:MM or in N seconds
--tcp build a TCP connection to transmit files
--tcp-server open socket, wait for connection
-u, --unlink unlink file after transmission
-U, --unrestrict turn off restricted mode (if allowed to)
-v, --verbose be verbose, provide debugging information
-w, --windowsize N Window is N bytes (Z)
-X, --xmodem use XMODEM protocol
-y, --overwrite overwrite existing files
-Y, --overwrite-or-skip overwrite existing files, else skip
--ymodem use YMODEM protocol
-Z, --zmodem use ZMODEM protocol
short options use the same arguments as the long ones
More information can be used for reference linuxprobe.com。
linux系统下怎么使用git
git命令是用来管理文件的程序,它十分类似DOS下的Norton Commander,具有互动式操作界面。它的操作方法和Norton Commander几乎一样:
git pull:从其他的版本库(既可以是远程的也可以是本地的)将代码更新到本地,例如:'git pull origin master'就是将origin这个版本库的代码更新到本地的master主枝,该功能类似于SVN的update
git add:是将当前更改或者新增的文件加入到Git的索引中,加入到Git的索引中就表示记入了版本历史中,这也是提交之前所需要执行的一步,例:'git add app/model/user.rb'就会增加app/model/user.rb文件到Git的索引中
git rm:从当前的工作空间中和索引中删除文件,例如'git rm app/model/user.rb'
git commit:提交当前工作空间的修改内容,类似于SVN的commit命令,例如'git commit -m story #3, add user model',提交的时候必须用-m来输入一条提交信息
git push:将本地commit的代码更新到远程版本库中,例如'git push origin'就会将本地的代码更新到名为orgin的远程版本库中
git log:查看历史日志
git revert:还原一个版本的修改,必须提供一个具体的Git版本号,例如'git revert bbaf6fb5060b4875b18ff9ff637ce118256d6f20',Git的版本号都是生成的一个哈希值
git branch:对分支的增、删、查等操作,例如'git branch new_branch'会从当前的工作版本创建一个叫做new_branch的新分支,'git branch -D new_branch'就会强制删除叫做new_branch的分支,'git branch'就会列出本地所有的分支
git checkout:Git的checkout有两个作用,其一是在不同的branch之间进行切换,例如'git checkout new_branch'就会切换到new_branch的分支上去;另一个功能是还原代码的作用,例如'git checkout app/model/user.rb'就会将user.rb文件从上一个已提交的版本中更新回来,未提交的内容全部会回滚
git rebase:用下面两幅图解释会比较清楚一些,rebase命令执行后,实际上是将分支点从C移到了G,这样分支也就具有了从C到G的功能
linux环境gitpush获取参数自动设置用户名密码
1、进入到git项目的根目录下,打开.git目录下的config文件cd.gitvimconfig添加如下内容[credential]helper=store。
2、进入项目目录命令:gitconfig--globalcredential.helperstore然后会生成一个本地文件用于记录用户名和密码,这个文件无需关心再次gitpull一下,会让输入用户名和密码。这次输入之后以后就不会每次输入了。
网页名称:关于linuxgit命令的信息
转载来于:http://scyanting.com/article/phcioc.html