6

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
gsamaras
  • 71,951
  • 46
  • 188
  • 305
Jason
  • 12,229
  • 20
  • 51
  • 66

5 Answers5

19
  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.
dlackty
  • 1,861
  • 14
  • 17
  • 1
    I've added certain unwanted files by mistake on the git add operation, how do I revert back saying I don't want to add few files – Jason Aug 12 '11 at 06:53
  • 3
    use "git reset HEAD ..." to remove files from commit. – dlackty Aug 12 '11 at 06:55
2
  • 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
  • First do step 4 "git remote -v". If the repository's URL is already listed you can skip step 3. In step 5 don't use "-f" because it's going to overwrite changes made by other people. First do "git pull origin master" and fix the conflicts, then make a pull request to the owner. – Enric Naval May 25 '23 at 14:23
1

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

Community
  • 1
  • 1
Kracekumar
  • 19,457
  • 10
  • 47
  • 56
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)
Priyanka Arora
  • 409
  • 4
  • 10
0

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 = git@github.com: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

Ricky Levi
  • 7,298
  • 1
  • 57
  • 65