git的一些基本命令总结

最近刚刚开始使用Git,对于所有的一些命令以及环境都不是很熟,这里个人总结一下。

1.git的安装和初次使用配置

   ubuntu安装git下直接命令

sudo apt-get install git

   git一般和repo一起使用,所以需要配置repo

#you can rename the dir according to your habits
mkdir [devDir] && cd [devDir]

#--------------------------------------------------------
#references: https://source.android.com/source/downloading.html
#install repo 
#you can change the dir but you must ensure the dir is included in your PATH
mkdir ~/bin
PATH=~/bin:$PATH

#Download Repo and ensure it is executable
#make sure the dir the same as before
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

   初次使用git需要配置user.name以及user.email

#First time must set user.name and user.email
git config user.name "[username]"
git config user.email [username@example.com]

   初始化repo,也就是通过ssh与相应的git服务其建立链接

#initialize repo 
repo init -u ssh://[url].git

   最后一部同步代码

#until now you can Sync codes from the git
repo sync 

至此相应的开发代码已经同步到对应的目录[devDir]下。

注:以上命令中,带有"[ ]"的都是需要根据实际情况替换的。


2.开发过程中使用git的一般流程

   同步代码,前面已经说过;

   创建分支

git branch [branch] --track origin/[branch]

   

  关联分支

git branch [branch] --set-upstream origin/[branch]


  查看分支状态

git branch


  切换到[branch]分支

git checkout master


  将修改完毕的code加入到暂存区
git add .

  查看当前暂存区状态

git status

  将暂存区的修改提交到本地库

git commit -s -m "comment"


  上传项目代码到服务器git系统

repo upload .


慢慢熟练,不断完善中~~~~~~~加油!!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值