How to synchronize a GitHub fork? - github

I'm trying to follow instruction found here, but it fails on the very first step:
C:\wxFork [master +42 ~0 -32 !]> git fetch upstream
fatal: 'upstream' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
What do I do?
Thank you.

You need to add your upstream first by adding it explicitly to your list of remotes:
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
Doing a git remote -v should show your upstream and now the git fetch upstream should work for you

Related

how can I cherry pick from upstream to my fork

I am very new in git hub my apologies for this naive question
I just forked a repository and I want to cherry pick from the original repo to my fork
here is what I did
git cherry pick 9fb44607a2ae89fb5b3a6b81sssdfsdadb0ec5
but I got this error
fatal: Unknown commit 9fb44607a2ae89fb5b3a6b81sssdfsdadb0ec5
what is the proper command to do such action
thank you
but I am using real hash when I run the command
If that real hash:
come from the upstream repository (the one you have forked)
has been created after your fork
You would then need to fetch from upstream in order for that commit to be present in your local repository (clone of your fork).
cd /path/to/my/cloned/fork
git remote add upstream https://url/original/repository
git fetch upstream
Then you can cherry-pick that SHA1.

How to keep git fork up to date

I have tried
git remote add upstream https://github.com/CSSEGISandData/COVID-19.git
and I get "not a git repository". I just want to keep the fork in sync with the root or whatever it's called. There's a new file added for each day and I want to not have to delete all of my files and refork. I somehow managed to do it once but for some reason I am now apparently committing to the original or something, I have no absolutely no clue what I'm doing.
First, make sure you are working from a clone of your fork:
git clone https://github.com/[your git account]/[your git repo].git
That will make a local copy of the fork that was made on github.
To keep your fork up to date with the upstream changes, you need to add upstream as a remote, which is what it appears you are trying to do (make sure you are in the directory for the local copy of the repo, or git will complain):
cd [local clone directory]
git remote add upstream https://github.com/CSSEGISandData/COVID-19.git
Then fetch upstream:
git fetch upstream
Then check out your master branch, and merge the upstream version:
git checkout master
git merge upstream/master
Note that git checkout master means the master from your fork, which we're assuming is missing some changes from the upstream source, which is then being merged in on the next line.

Unable to push local repository to GitHub

Unable to push local repository to GitHub
Steps followed:
mkdir github-local
cd github-local
git init
touch README.md
git add .
git commit -m "test commit"
git remote add origin git#github.com:sounak-patra/github-local.git
git remote -v
git push --set-upstream origin master
Output:
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Create the remote repository first in order to push into that repository. Before trying to add remote repository (step #7) you must create the remote repo.
The error is self explanatory:
ERROR: Repository not found. fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

How to update forked repo from GitHub Web?

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").

fatal: https://github.com/user/repo.git/info/refs not found: did you run git update-server-info on the server?

I am running the following script to set up a git repository on GitHub:
Global setup:
git config --global user.name "Your Name"
git config --global user.email email_id#email.com
Next steps:
mkdir MultiView
cd MultiView
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin https://github.com/nalgene/MultiView.git
git push -u origin master
The last line git push -u origin master or git push origin master for that matter returns an error:
fatal: https://github.com/naglene/MultiView.git/info/refs not found: did you run git update-server-info on the server?
I researched the issue and it seems the most likely reason is a typo (case sensitive) but I made sure that is not an issue. I used git remote -v to check the origin is correct. What else can be the issue?
You have to carefully look after your spelling. According to Github's guide, your username is nalgene, hence the URL is https://github.com/nalgene/MultiView.git. The error message hints that you added the remote as https://github.com/naglene/MultiView.git which is not the same username, as you swapped the l and g.
Also, the default branch is called master, not maaster or mater.
With Github, you must first make sure that you've made the repository on github itself before trying to push to it from your side. See this answer:
https://stackoverflow.com/a/12407847/735614
Did you make the repo there? Or are you only making it on your side and trying to create it on the server by pushing?
This is almost too obvious to mention, but this can also happen if you forget to create a new repository on Github before running git push.