部署学习git html
github :https://github.com/node
[root@node3~]#yum list all git*linux
yum -y install git -ygit
git clone github
git clone ;git init 构建本地仓库:vim
[root@node4~/testapp]#git init
Initialized empty Git repository in /root/testapp/.git/api
[root@node4~/testapp]#git help config服务器
[root@node4~/testapp]#git config -l
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=trueapp
git 配置文件: git config
仓库特有:REPO/.git/config
全局: ~/.gitconfig --global 指的是某我的配置
系统:/etc/git/config -system 公共配置
user.name user.email
git 仓库:
索引:暂存; 对象库:版本库ide
添加用户名及邮箱:
[root@node4~/testapp/.git]#git config --add user.name mage
用户: git config --global --add user.name mage
[root@node4~/testapp/.git]#cat ~/.gitconfig
git add /---/ git commit
[root@node4~/testapp/.git]#cp /usr/share/doc/git-1.8.3.1/technical/api-quote.txt ../
[root@node4~/testapp]#git add api-quote.tx
[root@node4~/testapp/.git/objects/e8]#git ls-files -s (--stage
100644 e8a1bce94e05f06c5b2aa51d2b610fb9da15d0bb 0 api-quote.txt
[root@node4~/testapp/.git/objects/e8]#git ls-files -s
100644 e8a1bce94e05f06c5b2aa51d2b610fb9da15d0bb 0 api-quote.txt
[root@node4~/testapp/.git/objects/e8]#git cat-file -p e8a1bce94e05f06c5b2aa51d2b610fb9da15d0bb
该文件hash 实际值就是e8开头的值br/>[root@node4~/testapp]#ls
api-quote.txt
[root@node4~/testapp]#git hash-object api-quote.txt
b6087d95c055fb753e5a1974231ebe76e970305d
git ls-file :列出文件;
-s :列出暂存区(stage area )中的文件对象
git cat -file :查看文件
-p 美观派出版显示文件内容
[root@node4~/testapp]#git commit
commit :索引对象和提交对象
注释: api_quote.txt 的hash 值就是b6
[root@node4~/testapp]#git hash-object api-quote.txt
b6087d95c055fb753e5a1974231ebe76e970305d
git log
本地git clone
git clone
git config --global user.name “name“ #设置全局用户名,能够非真实帐户
git config --global user.email xxx@xx.com #设置全局邮箱,能够非真实邮箱
git config --global –list #列出用户全局设置
git add index.html #添加文件到暂存区
git commit -m “11“ #提交文件到工做区
git status #查看工做区的状态
git push #提交代码到服务器
git pull #获取代码到本地
git log #查看操做日志
vim .gitignore #定义忽略文件
git reset --hard HEAD^ #git版本回滚, HEAD为当前版本,加一个^为上一个,^^为上上一个版本
git reflog # #获取每次提交的ID,可使用--hard根据提交的ID进行版本回退
git reset --hard 5ae4b06 #回退到指定id的版本
#git branch #查看当前所处的分支
git checkout -- file #从服务器更新某个那文件覆盖本地的文件
工做区:索引区 :对象库
[root@node4/tmp/testapp]# git help -a
git ls-files -s
git ls-files -o
git commit -m "0.1" 放在对象库中,"删除比较麻烦"
rm #删除工做目录
git rm #删除索引和工做目录
git rm --cached #删除索引
git ls-files -o 查看没有提交的
修改工做文件名称:
git mv passwd password
git ls-files -o
git log
refs/heads/REF:本地特性分支名称
refs/remotes/REF:远程跟踪分支名称
git help branch
git branch --list
git branch develop
git show-branch
切换分支 ;
git checkout develop ;git branch --list ;git show-branch 查看当前分支
git show-branch 当前使用的分支; git checkout master ;切换分支;
;git branch --list ;git merge develop
git status 显示工做状态;
git checkout develop
merge 冲突:
冲突 ,手动 删除,合并; git diff
a 是上次提交
b 是工做目录
版本回滚:
推到远程服务器上:
git fetch :取回远程服务器的更新
git pull 取回远程服务器更新,然后与本地的指定分支合并
git pull <远程主机名> <远程分支名>:<本地分支名.>
git push :将本地的更新推进到远程主机名
git push <远程主机名> :<本地分支名>:<远程分支名>
git push seaweedfs :master #删除远程分支
git clone
更新拖到本地
远程分支和本地分支合并
echo "# hadoop" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M master
git remote add origin git@github.com:linux-deb/hadoop.git
git push -u origin master
git remote add origin git@github.com:linux-deb/hadoop.gitgit branch -M mastergit push -u origin master