【git版本管理操作案例】
一、Server 端操作
[[email protected] ~]# git
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.
[[email protected] ~]# git --version
git version 1.7.1
[[email protected] ~]# useradd git
[[email protected] ~]# passwd git
Changing password for user git.
New password:
BAD PASSWORD: it does not contain enough DIFFERENT characters
BAD PASSWORD: is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.
[[email protected] ~]# mkdir -p /opt/gitrepository
[[email protected] ~]# chown -R git:git /opt/gitrepository/
[[email protected] ~]# su - git
[[email protected] ~]$ cd /opt/gitrepository/
[[email protected] gitrepository]$ mkdir pro1
[[email protected] gitrepository]$ cd pro1/
[[email protected] pro1]$ git init --bare
Initialized empty Git repository in /opt/gitrepository/pro1/
[[email protected] pro1]$ pwd
/opt/gitrepository/pro1
[[email protected] pro1]$ ls
branches config description HEAD hooks info objects refs
[[email protected] pro1]$ du -sh *
4.0K branches
4.0K config
4.0K description
4.0K HEAD
48K hooks
8.0K info
12K objects
12K refs
[[email protected] pro1]$ du -sh *
4.0K branches
4.0K config
4.0K description
4.0K HEAD
48K hooks
8.0K info
236K objects
16K refs
[[email protected] pro1]$
二、客户端操作
1)克隆仓库
2)输入口令,下载项目
3)克隆完毕
4)添加文件
5)提交到本地仓库
6)提交到远程仓库
三、结果验证
克隆前后文件变大了,因此实验成功
原创不易,欢迎打赏,请认准正确地址,谨防假冒