Git 使用手册

配置远程代码库(远程主机)

mkdir xxx.git
cd xxx.git
git init --bare  //创建裸仓库

本地操作

  • 情况1:代码在远程版本库,想拉到本地
git clone ssh://username@ip地址/xxx.git myproject

注:git clone命令会自动创建本地的 master 分支用于跟踪远程仓库中的 master 分支(假设远程仓库确实有master 分支)

  • 情况2:代码在本地,想推送代码到远程空版本库(需要先在远程主机创建裸仓库)
git init	//创建本地版本库
git remote add [remote-name] ssh://username@ip地址/xxx.git  //添加远程版本库
git push [remote-name] [branch-name]   //推送到远程版本库

常用git命令介绍

git config

  • 设置登录凭据保存,下次push时不需要输入远程仓库的用户名和密码。
git config --global credential.helper store
  • 删除保存的用户名密码
git config --global --unset credential.helper

git status

查看git仓库状态

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   a.txt

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   GameServerDev/script/make_all.bat

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        GameServerDev/application/db/ebin/account_to_player_id_db.beam

Changes not staged for commit:表示已在仓库中的,且状态发生改变(修改、删除)的文件。

fetch、pull

git fetch [remote-name]  //从远程仓库抓取数据到本地,但不合并到本地分支
git pull [remote-name]   //从远
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值