linuxgit命令行的简单介绍

linux系统下怎么使用git*初始化git仓库 , 使用git init命令
 *添加文件到git仓库分两步:
1、使用git add filename ;可分多次使用,添加多个文件到暂存区
2、使用git commit -m “说明” ;完成提交到分支
*查看工作区状态,使用git status 命令;如果提示有修改可使用git diff filename 查看修改内容
*HEAD指向当前版本,HEAD^表示上一个版本,HEAD^^上上一个版本……HEAD~100指向之前第100个版本 。
*回退版本:使用git log查看提交历史;使用git log --pretty=oneline 精简显示
使用git reset --hard commit_id 回退到版本号为commit_id的版本
*回退版本之后如果想再看改回来 , 可以使用git reflog 查看历史命令,找出想改回的版本号,再使用git reset hard commit_id 返回即可 。
*注意:git跟踪并管理的是修改,而不是文件,如果一个文件修改并add之后 , 再次修改,如果不再次add就提交的话,只会提交第一次的修改 。命令详解可查看“Linux命令大全” 。
在Linux下搭建Git服务器众所周知,版本系统在开发环境中是必不可少的,但是我们可以把代码免费的托管到GitHub上,如果我们不原意公开项目的源代码 , 公司又不想付费使用,那么我们可以自己搭建一台Git服务器,可以用Gitosis来管理公钥 , 还是比较方便的 。
搭建环境:
服务器 CentOS6.6git(version 1.8.3.1)
客户端 Windows10git(version 2.11.1.windows.1)
1. 安装Git相关软件
Linux是服务器端系统,Windows作为客户端系统,分别安装Git
安装客户端:
下载 Git for Windows,地址:
安装完之后,可以使用Git Bash作为命令行客户端 。
安装Gitosis
出现下面的信息表示安装成功了
2. 服务器端创建git用户来管理Git服务
3. 配置公钥
在Windows上配置管理者,git服务器需要一些管理者,通过上传开发者机器的公钥到服务器,添加成为git服务器的管理者,打开git命令行
4. 配置gitosis
使用git用户并初始化gitosis
在Windows上机器上clone gitosis-admin到管理者主机
gitosis.conf: git服务器配置文件
keydir: 存放客户端公钥
配置 gitosis.conf 文件
在Windows管理者机器上创建本地test仓库 , 并上传到git服务端
提交到远程服务器
服务端会自动创建test仓库
5.添加其他git用户开发者
由于公司开发团队人数不断增多,手动添加开发者私钥到/home/git/.ssh/authorized_keys比较麻烦,通过上面的Windows机器的管理者统一收集其他开发者的私钥id_rsa.pub文件,然后传到服务器上,配置好后,用户即获得项目权限,可以从远程仓库拉取和推送项目,达到共同开发项目 。
推送完成后,新加进来的开发者就可以进行项目的开发了,后续增加人员可以这样添加进来,开发者直接把仓库clone下来就可以了 。
linux怎样命令行上传git你是你是要通过git命令上传东西,还是想上传git到服务器上面,你可以先通过yum安装git
# yum install git
已加载插件:fastestmirror, refresh-packagekit, security
设置安装进程
Loading mirror speeds linuxprobe.com from cached hostfile
base| 3.7 kB00:00
epel| 4.3 kB00:00
epel/primary_db| 5.9 MB00:05
extras| 3.4 kB00:00
hhvm| 2.9 kB00:00
shells_fish_release_2| 1.2 kB00:00
updates| 3.4 kB00:00
updates/primary_db| 821 kB00:01
upgrade| 1.9 kB00:00
virtualbox/signature|181 B00:00
virtualbox/signature| 1.1 kB00: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:
addAdd file contents to the index
bisectFind by binary search the change that introduced a bug
branchList, create, or delete branches
checkoutCheckout a branch or paths to the working tree
cloneClone a repository into a new directory
commitRecord changes to the repository
diffShow changes between commits, commit and working tree, etc
fetchDownload objects and refs from another repository
grepPrint lines matching a pattern
initCreate an empty git repository or reinitialize an existing one
logShow commit logs
mergeJoin two or more development histories together
mvMove or rename a file, a directory, or a symlink
pullFetch from and merge with another repository or a local branch
pushUpdate remote refs along with associated objects
rebaseForward-port local commits to the updated upstream head
resetReset current HEAD to the specified state
rmRemove files from the working tree and from the index
showShow various types of objects
statusShow the working tree status
tagCreate, 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
- , --appendappend to existing files
-a, --asciiASCII transfer (change CR/LF to LF)
-b, --binarybinary transfer
-B, --bufsize Nbuffer N bytes (N==auto: buffer whole file)
-c, --with-crcUse 16 bit CRC (X)
-C, --allow-remote-commands allow execution of remote commands (Z)
-D, --nullwrite all received data to /dev/null
--delay-startup Nsleep N seconds before doing anything
-e, --escapeEscape control characters (Z)
-E, --renamerename any files already existing
--errors Ngenerate CRC error every N bytes (debugging)
-h, --helpHelp, print this usage message
-m, --min-bps Nstop transmission if BPS below N
-M, --min-bps-time Nfor at least N seconds (default: 120)
-O, --disable-timeoutsdisable timeout code, wait forever for data
--o-syncopen output file(s) in synchronous write mode
-p, --protectprotect existing files
-q, --quietquiet, no progress reports
-r, --resumetry to resume interrupted file transfer (Z)
-R, --restrictedrestricted, more secure mode
-s, --stop-at {HH:MM| N}stop transmission at HH:MM or in N seconds
-S, --timesyncrequest remote time (twice: set local time)
--syslog[=off]turn syslog on or off, if possible
-t, --timeout Nset timeout to N tenths of a second
-u, --keep-uppercasekeep upper case filenames
-U, --unrestrictdisable restricted mode (if allowed to)
-v, --verbosebe verbose, provide debugging information
-w, --windowsize NWindow is N bytes (Z)
-X--xmodemuse XMODEM protocol
-y, --overwriteYes, clobber existing file if any
--ymodemuse YMODEM protocol
-Z, --zmodemuse 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
- , --appendappend to existing destination file (Z)
-2, --twostopuse 2 stop bits
-4, --try-4kgo up to 4K blocksize
--start-4kstart with 4K blocksize (doesn't try 8)
-8, --try-8kgo up to 8K blocksize
--start-8kstart with 8K blocksize
-a, --asciiASCII transfer (change CR/LF to LF)
-b, --binarybinary transfer
-B, --bufsize Nbuffer N bytes (N==auto: buffer whole file)
-c, --command COMMANDexecute remote command COMMAND (Z)
-C, --command-tries Ntry N times to execute a command (Z)
-d, --dot-to-slashchange '.' to '/' in pathnames (Y/Z)
--delay-startup Nsleep N seconds before doing anything
-e, --escapeescape all control characters (Z)
-E, --renameforce receiver to rename files it already has
-f, --full-pathsend full pathname (Y/Z)
-i, --immediate-command CMD send remote CMD, return immediately (Z)
-h, --helpprint this usage message
-k, --1ksend 1024 byte packets (X)
-L, --packetlen Nlimit subpacket length to N bytes (Z)
-l, --framelen Nlimit frame length to N bytes (l=L) (Z)
-m, --min-bps Nstop transmission if BPS below N
-M, --min-bps-time Nfor at least N seconds (default: 120)
【linuxgit命令行的简单介绍】-n, --newersend file if source newer (Z)
-N, --newer-or-longersend file if source newer or longer (Z)
-o, --16-bit-crcuse 16 bit CRC instead of 32 bit CRC (Z)
-O, --disable-timeoutsdisable timeout code, wait forever
-p, --protectprotect existing destination file (Z)
-r, --resumeresume interrupted file transfer (Z)
-R, --restrictedrestricted, more secure mode
-q, --quietquiet (no progress reports)
-s, --stop-at {HH:MM| N}stop transmission at HH:MM or in N seconds
--tcpbuild a TCP connection to transmit files
--tcp-serveropen socket, wait for connection
-u, --unlinkunlink file after transmission
-U, --unrestrictturn off restricted mode (if allowed to)
-v, --verbosebe verbose, provide debugging information
-w, --windowsize NWindow is N bytes (Z)
-X, --xmodemuse XMODEM protocol
-y, --overwriteoverwrite existing files
-Y, --overwrite-or-skipoverwrite existing files, else skip
--ymodemuse YMODEM protocol
-Z, --zmodemuse ZMODEM protocol
short options use the same arguments as the long ones
More information can be used for reference linuxprobe.com 。
linuxgit命令行的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于、linuxgit命令行的信息别忘了在本站进行查找喔 。

    推荐阅读