【发布时间】:2011-08-12 06:08:10
【问题描述】:
我在 github 中创建了一个项目,然后对该项目进行了 git clone 以将所有源代码获取到我的机器上。
我对源代码做了一些修改,我的问题是:-
- 如何将我的更改提交到本地 git 存储库以及我在 github 中的分叉存储库?
- 原始源代码的作者将如何从 github 的分叉存储库中提取我的更改
【问题讨论】:
我在 github 中创建了一个项目,然后对该项目进行了 git clone 以将所有源代码获取到我的机器上。
我对源代码做了一些修改,我的问题是:-
【问题讨论】:
- 如何将我的更改提交到本地 git 存储库以及我在 github 中的分叉存储库?
要为提交添加文件更改,请使用以下命令。
git add .
然后,通过
进行本地提交git commit
完成本地提交后,您可以将其推送到远程 GitHub 分支。
git push
- 原始源代码的作者将如何从 github 的分叉存储库中提取我的更改
要使您的源代码被原始 fork 拉取,您必须向项目所有者发送 拉取请求。
【讨论】:
检查一下
Using GIT, how can I selectively pull / merge changes from another's 'fork'?How to commit my changes to the local git repositorygit 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
【讨论】:
【讨论】:
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)
【讨论】:
我正在使用已部署的密钥 (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 = git@github.com:USERNAME/REPOSITORY.git
fetch = +refs/heads/*:refs/remotes/origin/*
然后我确保在ssh-add -l(代理)中找到了我的密钥,然后我只是
git push
【讨论】: