三、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 $
