手机版
你好,游客 登录 注册
背景:
阅读新闻

Git 使用及实战教程

[日期:2013-03-15] 来源:Linux社区  作者:longerzone [字体:大 中 小]

三、Git 仓库实战

3.1 服务器端 Git 配置

1) 服务器端mkdir 一个文件夹,然后cd 进入该文件夹。

zyl@project ~ $ mkdir  study.git
zyl@project ~ $ cd study.git/
zyl@project ~/study.git $

2) 使用 git init 创建git 仓库,ls后,目录下有 .git 即可

zyl@project ~/study.git $ git init
Initialized empty Git repository in /home/zyl/study.git/.git/
zyl@project ~/study.git $ ls
zyl@project ~/study.git $ ls -a
.  ..  .git
zyl@project ~/study.git $

3) 本地创建一个文件,使用git add 以及 git commit

zyl@project ~/study.git $ touch first
zyl@project ~/study.git $ ls
first
zyl@project ~/study.git $ git add first
zyl@project ~/study.git $ git commit -m "my first push"
[master (root-commit) 9315d31] my first push
 Committer: zyl <zyl@project.lzu.edu.cn>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

If the identity used for this commit is wrong, you can fix it with:

    git commit --amend --author='Your Name <you@example.com>'

 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 first
zyl@project ~/study.git $

4) git remote 将Git 仓库推到远端,可供访问http://www.linuxidc.com

zyl@project ~/study.git $ pwd                               
/home/zyl/study.git
zyl@project ~/study.git $ git remote add origin zyl@project:/home/zyl/study.git
zyl@project ~/study.git $ git push origin master
Password:
Everything up-to-date
zyl@project ~/study.git $ git remote show origin
Password:
* remote origin
  Fetch URL: zyl@project:/home/zyl/study.git
  Push  URL: zyl@project:/home/zyl/study.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local ref configured for 'git push':
    master pushes to master (up to date)
zyl@project ~/study.git $

linux
相关资讯       Git教程  Git使用  Git使用教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款