Linux下git的安装及简单使用
2016-08-11 16:43
543 查看
[root@localhost /]# yum install git [root@localhost /]# git config --global user.name "Your Name" [root@localhost /]# git config --global user.email "email@example.com" [root@localhost /]# mkdir uter [root@localhost /]# cd uter [root@localhost uter]# git init 初始化空的 Git 版本库于 /uter/.git/ [root@localhost uter]# ls -ah . .. .git //前面几步操作我们已经成功安装了git并创建了一个版本库,如果需要把这个版本库取消那么直接把(.git)这个文件删除就可以了 [root@localhost uter]# rm -rf .git //现在我们试试把文件上传到版本库 [root@localhost uter]# vim git.txt [root@localhost uter]# git add git.txt [root@localhost uter]# git status # 位于分支 master # # 初始提交 # # 要提交的变更: # (使用 "git rm --cached <file>..." 撤出暂存区) # # 新文件: git.txt # [root@localhost uter]# git commit -m "linux test git" [master(根提交) c87e19d] linux test git 1 file changed, 1 insertion(+) create mode 100644 git.txt [root@localhost uter]# git log //查看版本信息 //在这里我直接对接我github上的远程仓库[已经建好的] [root@localhost uter]# git remote add origin https://github.com/xuedongyue/learngit.git [root@localhost uter]# git merge origin/master [root@localhost uter]# git push -u origin master 接下来我们回到浏览器返回 Github 创建的仓库刷新一下,就可以看到文件已上传到Github上: 查看当前的远程库: [root@localhost uter]# git remote [root@localhost uter]# git remote -v // -v 参数,可以看到每个别名的实际链接地址。 提取远程仓库: 1、从远程仓库下载新分支与数据 [root@localhost uter]# git fetch //该命令执行完后需要执行git merge 远程分支到你所在的分支。 2、从远端仓库提取数据并尝试合并到当前分支 [root@localhost uter]# git pull //该命令就是在执行 git fetch 之后紧接着执行 git merge 远程分支到你所在的任意分支。 假设你配置好了一个远程仓库,并且你想要提取更新的数据,你可以首先执行 git fetch [alias] 告诉 Git 去获取它有你没有的数据,然后你可以执行 git merge [alias]/[branch] 以将服务器上的任何更新(假设有人这时候推送到服务器了)合并到你的当前分支。 [root@localhost uter]# git fetch origin [root@localhost uter]# git merge origin/master (远程库名/分支名) 推送到远程仓库: [root@localhost uter] git push origin master
相关文章推荐
- Linux下git的安装及简单使用
- Linux下git的安装及简单使用
- MongoDB Primary---->简要介绍 和 Linux安装MongoDB 并 简单使用
- Git的初次使用 ; Git常用命令查询 ; Git push ; Git pull 2011-12-16 17:32 在介绍安装和简单使用前,先看一下百度百科中的简介吧: ———————————
- GIT在Linux上的安装和使用简介
- linux下,ssh服务安装和法git简单的使用方,整理实测。
- linux下git到安装、使用
- GIT在Linux上的安装和使用简介
- window下Linux 的安装和简单使用 & WMware Workstation 9.0中Linux(Red Hat) 的安装
- GIT在Linux上的安装和使用简介
- linux下git与github简单使用
- git+openssh 的安装与简单使用
- 在Linux下使用gitosis配置安装Git服务器
- 在Linux下使用gitosis配置安装Git服务器
- Git的初次使用 ; Git常用命令查询 ; Git push ; Git pull 2011-12-16 17:32 在介绍安装和简单使用前,先看一下百度百科中的简介吧: ———————————
- GIT在Linux上的安装和使用简介
- linux下bochs的安装及简单使用
- 在linux环境下安装Memcached及其简单使用+相关文档
- linux下git与github简单使用