git添加远程仓库与更新远程仓库

1、添加远程仓库

  要添加一个新的远程仓库,可以指定一个简单的名字,以便将来引用,运行 git remote add [shortname] [url]:

  $ git remote

  origin

  $ git remote add pb git://github.com/paulboone/ticgit.git

  $ git remote -v

  origin git://github.com/schacon/ticgit.git

  pb git://github.com/paulboone/ticgit.git现在可以用字串 pb 指代对应的仓库地址了.比如说,要抓取所有 Paul 有的,但本地仓库没有的信息,可以运行 git fetch pb:

       pb 是git push 命令中的 <远程主机名>,当把本地master分支的更新推送到远程主机,可以使用:

       git push pb master

2、git push origin master (第一次请加上参数-u,代表关联本地与远程) 意思是将本地的master分支推送到远程库(origin代表远程库)

git push命令用于将本地分支的更新,推送到远程主机。它的格式与git pull命令相似。

$ git push <远程主机名> <本地分支名>:<远程分支名>

3、把某次commit合入当前分支

 git cherry-pick <commit-id>

        转移一系列的连续提交(包含起始commit)

git cherry-pick <起始 commit 的 SHA-1 值>^..<结束 commit 的 SHA-1 值>

4、查看所有的历史commit

git reflog // 即reference log 可以参考的log

5、"detached HEAD" state

 a "detached HEAD" state refers to a situation where you are no longer on a branch, but instead you are directly pointing to a specific commit.
When you are in a detached HEAD state, any changes you make will not be associated with a branch, and if you create a new commit, it will not be part of any branch.

6、

# Your branch is ahead of 'origin/<branch_name>' by 2 commits.
#   (use "git push" to publish your local commits)

查看本地分支比远程分支多出的commit:

git log origin/<branch_name>..<branch_name>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值