如何将我的更改推送回 git 中的源代码

发布于 2024-11-29 17:40:21 字数 225 浏览 3 评论 0原文

我在 github 中分叉了一个项目,然后在该项目上进行了 git 克隆,以将所有源代码获取到我的机器上。

我对源代码做了一些修改,我的问题是:-

  1. 如何将我的更改提交到本地 git 存储库以及 github 中的分叉存储库?
  2. 原始源代码的作者将如何从 github 的分叉存储库中提取我的更改

I forked a project in github and then did a git clone on this project to get all the source code to my machine.

I have made some modifications to the source code and my questions are:-

  1. How to commit my changes to the local git repository as well as my forked repository in github?
  2. How will the author of the original source code, pull my changes from the forked repository in github

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

天荒地未老 2024-12-06 17:40:21
  1. 如何将更改提交到本地 git 存储库以及 github 中的分叉存储库?

要添加文件更改以供提交,请使用以下命令。

git add .

然后,进行本地提交,

git commit

一旦进行本地提交,您就可以将其推送到远程 GitHub 分支。

git push
  1. 原始源代码的作者将如何从 github 的分叉存储库中提取我的更改

要使原始分叉提取您的源代码,您必须向项目所有者发送拉取请求

  1. 转到 GitHub 上您的分叉项目的网页。
  2. 点击页面右上角的拉取请求按钮
  3. 选择您想要通过更改提交按钮提交的提交。
  4. 写下您的更改、评论等的一些描述。
  5. 发送拉取请求并等待所有者回复。
  1. How to commit my changes to the local git repository as well as my forked repository in github?

To add files changes for commit, use the following command.

git add .

then, make a local commit by

git commit

once you make your local commit, you can then push it to your remote GitHub fork.

git push
  1. How will the author of the original source code, pull my changes from the forked repository in github

To make your source code pulled by original fork, you have to send a pull request to the project owner.

  1. Go to the web page of your forked project on GitHub.
  2. Hit the pull request button on the top right of page
  3. Select the commits that you want to submit by change commits button.
  4. Write some description of your changes, comments, or etc.
  5. Send pull request and wait for the owner reply.
仅此而已 2024-12-06 17:40:21
  • 这是简单的方法:
    1. git 添加。
    2. git commit -m“最终更改”
    3. git远程添加源url(在url中添加您的存储库的地址)
    4. git远程-v
    5. git Push -f
    6. git push origin master
  • Here's the simple way :
    1. git add .
    2. git commit -m "Final Changes"
    3. git remote add origin url(in url add the address of your repository)
    4. git remote -v
    5. git push -f
    6. git push origin master
纵山崖 2024-12-06 17:40:21

检查这个
使用GIT,如何选择性拉取/ 合并来自另一个“fork”的更改?
如何将我的更改提交到本地 git 存储库
git commit -m "Your Message"

如何在 github 的分叉存储库中提交我的更改?
http://www.backdrifter.com /2011/02/09/working-on-forked-projects-using-github/
http://help.github.com/fork-a-repo/

< code>原始源代码的作者如何从 github 的分叉存储库中提取我的更改
如何显示已上演的更改?< /a>
http://www.kernel.org/pub/ software/scm/git/docs/git-pull.html
http://www.kernel.org/pub/software/ scm/git/docs/everyday.html

Check this
Using GIT, how can I selectively pull / merge changes from another's 'fork'?
How to commit my changes to the local git repository
git commit -m "Your Message"

How to commit my changes in forked repository in github?
http://www.backdrifter.com/2011/02/09/working-on-forked-projects-using-github/
http://help.github.com/fork-a-repo/

How will the author of the original source code, pull my changes from the forked repository in github
How do I show the changes which have been staged?
http://www.kernel.org/pub/software/scm/git/docs/git-pull.html
http://www.kernel.org/pub/software/scm/git/docs/everyday.html

静若繁花 2024-12-06 17:40:21
    follow these steps:
    git init (To initialize the repository as git)
    git add .( To add the changes to staging area)
    git commit -m "this is my first commit" ( Initialize it as a commit with the message)
    git add remote origin url (in url add the address of your repository)
git pull origin master(to pull all the commits first otherwise they would be overridden)
    git -f push origin master(force push the chances to remote in the branch named master)
    follow these steps:
    git init (To initialize the repository as git)
    git add .( To add the changes to staging area)
    git commit -m "this is my first commit" ( Initialize it as a commit with the message)
    git add remote origin url (in url add the address of your repository)
git pull origin master(to pull all the commits first otherwise they would be overridden)
    git -f push origin master(force push the chances to remote in the branch named master)
蒗幽 2024-12-06 17:40:21

因此,我使用部署密钥( ssh )与带有用户/通行证的 http ( Repo -> Settings -> Deploy Keys

,在我 git clone 我的存储库之后,我必须手动更改(或使用 git remote 添加新的)以下内容
来自:

[remote "origin"]
    url = https://github.com/USERNAME/REPOSITORY.git
    fetch = +refs/heads/*:refs/remotes/origin/*

至:

[remote "origin"]
    url = [email protected]:USERNAME/REPOSITORY.git
    fetch = +refs/heads/*:refs/remotes/origin/*

然后我确保在 ssh-add -l (代理)中找到了我的密钥,然后我就
git 推送

I'm using deployed key ( ssh ) vs http with user/pass ( Repo -> Settings -> Deploy Keys )

therefor, after i git clone my repo, i had to manually change ( or add new one using git remote ) the following
from:

[remote "origin"]
    url = https://github.com/USERNAME/REPOSITORY.git
    fetch = +refs/heads/*:refs/remotes/origin/*

To:

[remote "origin"]
    url = [email protected]:USERNAME/REPOSITORY.git
    fetch = +refs/heads/*:refs/remotes/origin/*

Then i made sure my key was found in the ssh-add -l ( agent ) and then i just
git push

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文