I'm fairly new to GitHub, so I hope you can help out. There's a branch on a repo that I want to push changes to, but I'm not added as a collaborator on it. What steps do I need to take to push changes to that branch?
I have done some research and found that I may need to fork the repo, make changes locally then create a pull request, but I'm still a bit confused about it. I would appreciate any help.
You can't simply push to the branch which you dont have the write access. You can simply fork the repo by clicking it fork button. Then clone the repo locally by using the command below
git clone https://github.com/your-username/project.git
Then you need to checkout to the branch which you need to make the change just use:
git checkout branch_name
Then make the necessary changes. Now you will have to commit the changes:
git add --all .
git commit -m "changes description"
git push
Now visit the repository in your profile. You can see a notification to open a new pull request.
Please see this for more info: https://akrabat.com/the-beginners-guide-to-contributing-to-a-github-project/
Related
I am working with GitHub and want to submit a pull request. When I fork the repository I don't see my changes I'm guessing because it never asked me where to link the repository to. How do I link the forked repo to a location on my personal computer for the pull request? This is for an interview and with the code done I don't know where (or how) to put it.
I'm the first to oppose noise but I don't know what other exchange site to post on. I'll close it if I'm pointed somewhere else and it doesn't get closed first.
If you have cloned the original repo locally, you can:
make sure you have a fork on GitHub (you seem to have one, where you say you don't see your changes, which is expected since you haven't push them yet)
declare that fork as your new origin
That is
cd /path/to/my/local/repo
git remote rename origin upstream
git remote add origin https://github.com/<myGitHubAccount>/<reponame.git>
Don't forget to add your changes, commit and push:
git checkout -b aNewBranch
git add .
git commit -m "Fix done in a new branch for PR (Pull Request)"
git push -u origin aNewBranch
From there, you can go to https://github.com/<myGitHubAccount>/<reponame.git>, switch to aNewBranch, and click "Make a Pull Request"
I found good project (boilerplate), which I am going to use as starting point for my project.
And I forked it.
git clone https://github.com/fork.git forkdirectory # clone my fork to my local PC
git branch mybranch # create new branch for my specialities, which will be different from boilerplate
git checkout steklo # change the branch, which I will work on by default
Then I make some changes and check that they appear in my fork
git add . # add all changes for commit
git commit -m"commit comments" # make commit
git push -u origin mybranch # push changes to mybranch
I tested that for next changes I can just do shorter
git push
But what should I do when I will see that initial boilerplate updated?
1) How to apply all updates to my fork?
2) And then how to apply all updates from my fork to my local clone?
I think i understand your confusion about it,
This process steps are
Fork the repository.
Update the repository.
Create a pull request
Now Owner of the repository sees, if your request is valid, he merge the request.
You've already completed first two steps, now you only need to submit a pull request.
Goto Pull requests of your forked repo
Create a new pull request
Owner will see if it is valid then he will merge your pull request to the repo
that's all
Cheers :)
I've forked a repo, and checkout a new branch, modified and rebased it on the upstream/master. I want to create a pull request now, and I couldnt see the new branch I have created. Could it be on a different remote? Is there a way to see this?
Thanks
How to submit a pull request from an existing locally-cloned repo?
Often, I want to look at some libraries source code from github, so I clone it. Later, I discover some issue with the code and raise it on a mailing list, often in passing. The library author says "nice find, can you send a pull request?".
And the answer is "not that easily". I haven't forked the repo yet, Ive cloned it. And there doesn't seem a way I can find to submit a pull request from a cloned repo?
If this limit is true, it feels like the sensible reaction is to fork anything and everything you ever look at, just so that if you ever might want to contribute, you can. And that fills up your github account with many inactive forks.
Doesn't seem a lot of talk about this issue - am I the only person whom this problem affects?
Fork the repo on GitHub, then add your fork repo as a remote to your local cloned copy:
git remote add myfork https://github.com/<myGitHubAccountName>/<repoName>.git
Then you can push to your fork:
git push myfork master
If you're doing more than just this one pull request, you can remove the origin remote and name your fork as origin:
git remote rm origin
git remote add origin https://github.com/<myGitHubAccountName>/<repoName>.git
This is typically what I do. Sometimes I add the original origin as upstream so I still have a reference to it.
If you're ok with installing another binary in your path, github has released a nice little tool called hub.
If you've cloned someone else's repo:
$ hub fork # This creates a fork and adds your repo as a remote
$ git push YOUR_USER feature # push the changes to your new remote
$ hub pull-request # will open your browser
I always clone instead of fork as well and the following steps work for me:
Create a new branch on your cloned repo and make the new change.
Push the change to your branch as the following:
git push origin insert_your_working_branch_name
Now you should be able to find your working branch in pull request from github master.
Are github pages within my account created automatically when I fork a repo which already includes gh-pages branch?
There needs to be at least one push to trigger a page build so by doing a git push origin master, I got the page to rebuild.
An elegant approach:
git push -f origin gh-pages^:gh-pages
git push origin gh-pages:gh-pages
git push origin master might not be good because if there might already be something on master. The above should always work, as it just wobbles the remote branch back and forward.
Taken from: Pushing without committing , whose solutions are also solutions to this question.
Forking a repository within Github is not sufficient by itself to trigger the creation of the Github Pages.
Either of these two things will work:
Edit and save any page using the Github interface. For example, modify the README.md file, even just adding a space.
Make any kind of git push to the gh-pages branch. As others have suggested, a trivial non-change you can make is:
git push -f origin origin/gh-pages^:gh-pages
git push origin origin/gh-pages:gh-pages
This force-pushes the penultimate commit to be the gh-pages HEAD, then fixes it.
After you fork a github page repo, you can change any file on github page and commit it, your web site will appear without using git.
Renaming the forked repository would work too.
No, after you fork a repo, you have to publish it again. To do this, run the following commands on a local clone:
git push -f origin origin/gh-pages^:gh-pages
git push origin origin/gh-pages:gh-pages
This triggers the publisher hook twice, but you don't have to commit anything.
You would have to publish it afresh from your forked repo directory
Run:
git push origin main