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

时间:2011-08-12 06:08:11

标签: git github git-push

我在 github 中分叉了一个项目,然后在这个项目上做了一个 git clone 来获取我机器的所有源代码。

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

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

5 个答案:

答案 0 :(得分:8)

  
      
  1. 如何将我的更改提交到本地git存储库以及我在github中的forked存储库?
  2.   

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

git add .

然后,通过

进行本地提交
git commit

进行本地提交后,可以将其推送到远程GitHub fork。

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

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

  1. 转到GitHub上的分叉项目的网页。
  2. 点击页面右上角的拉取请求按钮
  3. 通过更改提交按钮选择要提交的提交。
  4. 写下您的更改,评论等的一些说明。
  5. 发送提款请求并等待所有者回复。

答案 1 :(得分:1)

检查这个 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

答案 2 :(得分:0)

    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)

答案 3 :(得分:0)

  • 这是简单的方法:
    1. git add。
    2. git commit -m“最终更改”
    3. git remote add origin url(在url中添加您的存储库地址)
    4. git remote -v
    5. git push -f
    6. git push原始主机

答案 4 :(得分:0)

我正在将已部署密钥(ssh)与带有用户/密码(Repo -> Settings -> Deploy Keys的http一起使用)

因此,在我git clone我的仓库之后,我不得不手动更改(或使用git remote添加新的仓库)以下内容 来自:

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

收件人:

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

然后,我确保在ssh-add -l(代理)中找到了我的密钥,然后我只是 git push