How to update forked repo from GitHub Web? - github

I want to update a forked repo from GitHub web interface.
I tried a few things from other questions but it gave me fatal: not a git repo when I use git remote add upstream git://blabla

Try using an https address first, as mentioned in GitHub FAQ:
git remote add upstream https://github.com/octocat/Spoon-Knife.git
# if upstream already exist
git remote set-url upstream https://github.com/octocat/Spoon-Knife.git
And make sure of the case used in this address (it is case-sensitive, and the slightest error will give you "not a git repo").

Related

how to solve the requested URL returned error: 403 on bitbucket? and setup to push both on github and bitbucket?

I forked a repo from bitbucket for my internship test. I worked on it. then I did:
git init
hub create
now when i have to push to bit bucket and I want
to push also on github but i get this error:
unable to access 'https://bitbucket.org/aaa/bbb.git/': The requested
URL returned error: 403
I never used bitbucket and always github. I wanna be able to use both. The repo is open to everyone and I need to make a pull request to let them evaluate my code. I dont understand how need to install ssh key/bitbucket credentials on my local machine to access it. It seems confusing.
DOES anyone have any clue how to set up both bitbucket and github and fixing this error? I have to hand in by the end of the week and I am lost.
The repo is open to everyone
For pulling/cloning, yes, it is opened to everyone, not for pushing.
Only the owner/collaborators of the bitbucket.org/aaa/bbb.git can push to it, so if you want to make a pull request from a BitBucker repository, you need to push to to your fork, not the original repository.
You can push to multiple repositories:
git remote set-url --add --push origin https://github.com/<you>/<yourRepo>
git remote set-url --add --push origin https://bitbucket.org/<you>/<yourFork>
# Or, if you are using a registered SSH key to your BitBucket account
git remote set-url --add --push origin git#bitbucket.org:<you>/<yourFork>

Connect to github server

I have the ip, useename and password of the github server, which uses gitlab, and I need to connect to it and manage files. What should I do?
I'm assuming you're asking how to manage/change files within a git repository. If you're asking something else, I've missed the point, apologies.
Firstly you will need 'git' on your local machine - install it with your package manager or download and install it from the git website.
Once git is installed you can clone a repository (which contains a set of files, and ends in .git) using the git clone command. Run git clone --help for more information on this, but if you already know the address of your git server and the path to the repository, it will look something like as follows:
git clone https://git-server.url/path/to/repo.git
Note that the URL you should use will depend on the configured transport protocol (git, ssh, http[s]) of your git server.
Next, you should makes some local configurations, for example, from a terminal:
git config user.name "your_username"
git config user.email "someone#example.com"
You can add --global to both of these command if you want these changes to persist outside of the current git repo.
Having a cloned repository automatically checks out an initial 'branch' on which you can make changes to files within your repository. See the git docs for a detailed explanation of a branch.
Files can be added, removed or renamed/moved using git add, git rm or git mv respectively.
Finally, you must commit your changes and push them
git commit -m "A message describing your changes"
git remote will confirm the name of the default remote (repo location). In this case, it is assumed to be origin. You can then push your changes to an existing branch (viewed using git branch -r), assumed to be master below:
git push origin master
Here you would be merging your master branch with the remote one. Clearly your permissions/project conventions will dictate what you can/should do to this repo.

Error While commiting to Github

remote: Repository not found.
fatal: repository 'https://github.com/vivekghanchi/portfolio.git/' not found
You need first to create your repository in GitHub (it's done directly in your Web browser). Then you can do a git push to upload your local commits to the new repository.
Also, after creating your GitHub repository, make sure the url you are pushing to matches that of GitHub, I notice an extra / at the end of your url, which should not be there.
To see the url you are pushing to, issue:
git remote -v
the repository is deleted but I was committing to a new repository after than also it is showing this
Committing is a local operation.
Make sure your remote url matches the one of your new repo.
Update it with:
cd /path/to/my/local/repo
git remote set-url https://github.com/vivekghanchi/aNewRepo
Then try to push again:
git push
Pushing is not "committing to GitHub", but rather "publishing your local commits to your upstream GitHub repository".
You need first to create your repository in GitHub (it's done directly in your Web browser). Then you can do a git push to upload your local commits to the new repository.
Committing is a local operation.
or your can add already existing repo
git remote add origin remote repository URL

How do I change the remote source of my github repo?

I forked a repo and set everything up on my local machine. However, when I do 'git remote -v' it shows the original repo as my fetch and push source. I want it to by from my forked repo. How do I change it over to that without starting all over? And then, how do I add an upstream to the original repo?
From the git remote man page:
git remote set-url origin https://github.com/user/forkname
git remote add upstream https://github.com/maintainer/reponame
See also the examples of GitHub: Changing a remote's URL.
set-url
Changes URL remote points to.
You will then be able to fetch from upstream, and push to origin:
See "What is the difference between origin and upstream in Github".

How to push changes from a forked project to the original project?

I’m supposed to work on my client's project on GitHub, where the changes would be on his repository. I tried to follow the fork example, but could only get the changes to go to my account repository?
In the example on GitHub, to fork a repo, they create a remote called upstream to point to the original project. I can get the changes from it by
get fetch upstream
git merge upstream/master
I was able to upload the changes into my repo by
git push –u origin
which copied my changes to my account.
I tried
git push –u upstream
To push my changes on the original account. I got the following error
You can’t push to git://github.com.octocat/SpoonKnife.git
use git#github.comoctocat/Spoon0-Knife.git
Basically, in order to collaborate with your client, you've got two main options:
Send your client a pull request (more info on this in this GitHub help item). This allows your client to review, discuss and/or request some changes to your proposal before merging it.
Request from your client to be added as a committer to their project. This would allow you to directly push your commits to their repository, without the need for a fork/cloned repository on your side.
As a side note, Spoon-Knife.git is one of GitHub's read-only repository (used for demonstration purpose) and you will not be able to commit to that (unless your client is GitHub). Thus, your client's upstream git remote should point to a different repository
Here are the steps (to be followed after you forked and cloned the repository to your local disk):
Remove the upstream reference: git remote rm upstream
Add in your client's info - git remote add upstream git#xxxxxx
Push your changes - git push -u upstream master . git push -u will set the HEAD of the remote repository.
Same if you want to pull - git pull upstream master
If you prefer the name origin replace upstream with origin, but still follow step 1 to remove the reference to Spoon-Knife.git. Then in step 2 - git remote add origin git#xxxx.
git://github.com.octocat/SpoonKnife.git is a read-only URL. As GitHub suggests, the corresponding write-able URL is git#github.comoctocat/Spoon0-Knife.git.
If you want to be able to push on the upstream repository, you will have to ask (to the upstream team, i.e., your customer) to be added as a committer.