Git 常用命令基本操作以及含义

1. git clone -b develop_name  xxxxxxxx.git    // 克隆某一分支到本地

2. git pull original remote_branch : local_branch  // 从远程分支拉取到本地分支

3. git push original local_branch : remote_branch  // 将本地分支推送至远程分支

4. git init  // 初始化一个本地库,即就是将该工程用 git 管理起来

5. git status   // 查看当前 代码区,暂存区,本地库的状态

6. git add .   // 将所有变更文件添加到暂存区 (也可以使用 -u  参数)

7. git commit -m "comment_message"  // 将暂存区提交到本地库并添加提交信息

8. git branch -av  // 查看所有本地及远程分支,带 * 的为当前分支

9. git remote -v  // 查看所有的远程库别名及地址信息

10. git log --pretty=oneline /  git log --oneline  -n   // 以行为单位显示前 n 个日志记录

11. git reflog  // 查看每个 commit 的 index  方便回退版本使用,可以配合 --oneline -n 参数使用

12. git reset --hard index_value  /  git reset --hard HEAD^  /  git reset --hard HEAD~n  // 回退版本库的几种方法,推荐使用第一种

13. git checkout branch_name  // 切换到 branch_name  分支

14. git merge other_branch    // 将 other_branch 合并到当前分支(前提是已经处于当前分支)

15. git remote add alias_name https://github.com/xxxxx/xxxxx.git // 给远程库添加别名 alias_name

16. git branch -d branch_name  // 删除本地分支 branch_name;

17. git branch -m old_branch new_branch  // 将 old_branch 分支重命名为 new_branch

18. git push remote_alias_name --delete remote_branch_name  // 删除远程分支remote_branch_name

19. git 修改远程仓库url

      git remote set-url remote_name new_remote_url

      eg: git remote set-url origin_ssh git@github.com:USERNAME/OTHERREPOSITORY.git  (为ssh登录方式创建一个远程仓库别名)
 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值