git 常用操作
Linux搭建git服务器
1、服务器端创建Git仓库
[root@localhost home]# mkdir -p data/git/blog.git
[root@localhost home]# git init --bare data/git/blog.git
Initialized empty Git repository in /home/data/git/blog.git/
[root@localhost home]# cd data/git/
[root@localhost git]# chown -R git:git gittest.git/
2、客户端初始化Git本地库
选择一个空目录,右击空白处,Git Bash Here
$ git init 初始化
# git add xxx 是将当前文件夹下的指定文件添加到git的跟踪中,意思就是交给git经管,提交到本地库
$ git config --global user.email "xxxxx@qq.com"
$ git config --global user.name "XXX"
$ git commit -m "First Commit"
git add src # 将文件夹src提交到本地库
# 写提交信息
git commit -m "First Commit"
# 设置远程库
git remote add origin git@10.6.123.81:/home/git/sample.git
# 将本地变更推送到远程库
git push -u origin master
# 一些常用git命令
# 将远程库变更更新到本地库
git pull --rebase origin master
# 将github上的项目down下来。
git clone git@github.com:ellocc/gittest.git
# 状态查询命令
git status

浙公网安备 33010602011771号