提交另一个项目的特定提交

huangapple go评论71阅读模式
英文:

Commit specific commit of another project

问题

有没有办法将另一个用户在另一个存储库上创建的提交添加到我的存储库中,还是我需要手动逐个文件进行操作?

英文:

I have created a fork of a repository (https://github.com/datso/react-native-pjsip) And made my own changes on him, but there's another repository with changes (https://github.com/moisesynfam/react-native-pjsip/commit/845801c331b9a530a542fc18fb88217ee6ee8f5c) that i want to make on my own repository (https://github.com/willnaoosmit/React-native-sip-pjsip)

It's there a way to commit on my repository a commit made by another user on another repository? Or i need to make this file to file by hand?

答案1

得分: 2

以下是翻译好的部分:

你可以在本地副本上拥有多个远程仓库:

  • 选择如何命名这个第二个远程仓库(我将使用"moisesynfam"作为示例):

      git remote add moisesynfam https://github.com/moisesynfam/react-native-pjsip
    
  • 从这个仓库获取更改:

      git fetch moisesynfam
    
  • 现在,您可以访问其所有已发布的提交:

      git cherry-pick 845801c33
    

您仍然可以使用"origin"远程仓库将任何内容推送到您自己的克隆版本:

git push origin ...
英文:

You can have several remotes on your local copy :

  • choose how to name this second remote (I will use "moisesynfam" as an example) :

    git remote add moisesynfam https://github.com/moisesynfam/react-native-pjsip
    
  • fetch changes from this repo :

    git fetch moisesynfam
    
  • you can now access all of its published commits :

    git cherry-pick 845801c33
    

You can still push anything to your own clone using the origin remote :

git push origin ...

答案2

得分: 2

You will need to use cherry-pick

Follow these steps:

add the 2 remotes to your repository

git remote add

"Grab" the content of all the branches

git fetch --all --prune

Checkout the destination branch

git checkout

"Apply" the change

git cherry-pick

英文:

>It's there a way to commit on my repository a commit made by another user on another repository? Or i need to make this file to file by hand?

You will need to use cherry-pick

Follow these steps:

# add the 2 remotes to your repository
git remote add <origin2> <url>

# "Grab" the content of all the branches
git fetch --all --prune    

# Checkout the destination branch
git checkout <branch>

# "Apply" the change
git cherry-pick <SHA1->

提交另一个项目的特定提交


提交另一个项目的特定提交

huangapple
  • 本文由 发表于 2020年1月3日 22:39:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/59580462.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定