Cannot update sourcecode from remote repository to local repository - github

I try to update source code from remote repository to local repository by git command:
$git pull origin dev
The terminal has noticed:
From https://github.com/AAA/BBB
* branch dev -> FETCH_HEAD
Already up to date.
But the source code was not updated.
How can I solve this problem?

Have you tried confirming the git remote -v and see if it points to the right origin ?
Otherwise set the remote origin by
git remote set-url origin <remote-repo-url>

Related

GitHub - failed to create remote repository

I have a repository- 'repo1' in our company's GitHub cloud.
git remote -v, shows -
origin git#github.****:***/repo1.git (fetch)
origin git#github.****:***/repo1.git (push)
Now I am trying to add a new remote repo - 'repo2' with the command line:
projectName=repo2
mkdir $projectName
cd $projectName
git init -b $projectName
touch README.md
git add README.md
git commit -m 'Initial commit'
git remote add origin ****:***/repo2.git
git push -u origin $projectName
and I get an error in the last command:
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
It is worth emphasizing that the repo was created with local success.
also, git remote -v, shows
origin git#github.****:***/repo2.git (fetch)
origin git#github.****:***/repo2.git (push)
but failed to push to remote.
also is worth emphasizing, that I could add a new repo in our GitHub site. The only problem occurs when adding from the terminal.
I found on GitHub forums, that the new repo must be created on GitHub site before doing the git push

How to push changes to old repo to GITHUB after downloading it

I lost my PC data after hard-drive corruption. After that from my github repo i downloaded my code and made some changes and did npm install, but when i tried to push my changes to repo, it is saying there are no currently active repo to push.
How to push my new changes to my old repo?
You should have cloned the repo on your local machine, that way you would have the git initialized. But, for now, you can follow the below steps.
git init
git remote add origin <github repo url>
The first line would initialize the git repo and the second would point it to the online repo you already have.
You could have downloaded the repo with:
git clone <repo url>
but to answer your question:
git init
git add .
git commit -m "init"
git remote add origin <repo url>
you can then verify the remote url with:
git remote -v
after that check If your .gitignore file is there, if not create one and add node_modules/
after that just push it with:
git push -f origin master
just check whether you have set the remote origin correctly.
$ git remote show origin
$ git remote -v
use the above commands to check your remote URL. if it is not set correctly, set the URL again.
$ git remote set-url < your repo URL here >
hope this will work

Unable to push files in git repository

I am trying to push my files using git bash to online git repository using this command.
$ git push -u origin master https://github.com/SMAmmar/git-test.git
But after using it i am getting this error
fatal: invalid refspec 'https://github.com/SMAmmar/git-test.git'
How can I solve this problem? I am a newbie when using github so please elaborate what you guys are telling me to do.
From git push
git push <repository> [<refspec>…]
The "remote" repository that is destination of a push operation.
This parameter can be either a URL (see the section GIT URLS below) or the name of a remote (see the section REMOTES below).
So yes, git push can take a URL
But the order is important:
where you push (the URL or remote name)
what you push
In your case:
git push -u origin master
git push -u https://github.com/SMAmmar/git-test.git master
But not both origin and https://github.com/SMAmmar/git-test.git
The first form is preferred. Once that first command is working, a simple git push will be enough.
git push doesn't take a URL. Instead it takes the name of a remote repository that you've previously set up, that's origin, and a branch to push. origin is automatically set up when you git clone a repository.
If you run git remote -v you should see something like this:
origin https://github.com/SMAmmar/git-test.git (fetch)
origin https://github.com/SMAmmar/git-test.git (push)
If you see some other URL, use git remote set-url origin https://github.com/SMAmmar/git-test.git to make origin point at that URL.
Then git push origin master says to push your master branch to the master branch on the repository identified by origin which is https://github.com/SMAmmar/git-test.git.
See also
Working With Remotes
Managing Remote Repositories

github fork confusion

I followed this https://help.github.com/articles/fork-a-repo post to clone a repository locally. After doing that another developer created a branch to the main repository and added some features to that branch. My question is
How do I get that branch into my fork.
Can I get that missing branch again to my local using git pull upstream/missing_branch command?
Thank you
You need to add a remote repo 'upstream' in the local repo (which has for origin your fork)
(git remote man page)
git remote add upstream url://upstream/repo
The OP opensourcelover mentions seeing this:
git remote -v,
origin git#github.com:username/project.git (fetch)
origin git#github.com:username/project.git (push)
upstream git#github.com:username/project.git (fetch)
upstream git#github.com:username/project.git (push)
If your origin is the same as your upstream remote repo, you can replace that url by the https one for that upstream:
git remote set-url upstream https://github.com/originalDevName/originalRepoName
That way, you can git fetch upstream and get the new branch.
If you need to work on that new branch, you can now declare it:
git branch -u upstream/foo foo
See "How do you make an existing Git branch track a remote branch?".

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