I need help on Git/Github

Hello y’all, I seem to be struggling with Git/GitHub on VSCode as I’m new to it… Now to the problem, I have two repositories in my GitHub, I already pushed a project to “repo A” sometimes ago but while trying to push another project to “repo B” I get this error message.

“Can’t push to ref to remote. Try running ‘pull’ first to Integrate the changes”

The master seems to only pushes to “repo A” and not “repo B”… I did tried to pull first and push again. It doesn’t seems to work

How can I push this new project to a different repository? Thanks

I recently had a similar problem with not being to update an old resource and:

  1. “git cloned” the online resource to a new local directory
  2. copied all the old problematic local files to the recent cloned directory
  3. git add . // with trailing period
  4. git commit -m “message”
  5. git push

Checked and worked a treat… So deleted duplicate directory.

Your question isn’t really clear to me. Is it one project you want to push to 2 repositories, or 2 projects you want to push to 2 different repositories?

2 projects to 2 different repositories. Thanks

Thank you John… Sorry for asking these dumb questions but I have nothing inside the remote repository except from the readMe… Is it possible that I can still clone it to my local computer?

Secondly, talking about copying my file to the recent cloned directory, won’t this affect the relative path in my html document… Thanks!!

Try cloning the repository with just the readme to the local computer.

Afterwards copy files from the old local computer to the recently cloned repository.

I am not sure what you mean by the relative path.

Thanks once again John… After cloning, If I’m to work with project files in my text editor, is it going to be the files in the recently cloned repository I’d be working on or the former.

And also, can I delete the files from the old local computer after copying it to the cloned repository?

Lastly, for every repositories I create in the future, will I have to clone them all.


Git and Github have very strict rules which must be

I prefer examples:

I have an old Github Repository called “test-001” which is out of date.

I also have the source files on my local computer in the following directory /var/www/test-001 and unable to update the local directory to the Github Repository

Steps taken to update the local files to the Github Repository:

  1. Rename /var/www/test-001 to /var/www/ZZZ-test-001,

  2. Login to Github and select “test-001” Repository.

  3. Click on the green “Code” button and copy the SSH link: ‘https://github.com/YOUR-USER-NAME/test-001

  4. On your local computer navigate to where you would like to Clone the repository and emter the following in a command prompt window :

git clone ‘https://github.com/YOUR-USER-NAME/test-001

  1. Copy all source files and overwrite:
    from: /var/www/ZZZ-test-001/.
    to: /var/www/test-001/.

  2. In a command prompt window navigate to /var/www/test-001 and enter the following:
    a. git status
    b. git add .
    c. git commit -m “Message”
    d. git push

  3. Check online Github Repository and ensure all files have been uploaded.

  4. All files in the ‘/var/www/ZZZ-test-001/’ folder can be deleted perhaps after a couple of weeks :slight_smile:

  5. Editing of ‘/var/www/test-001/’ source files can now be updated to the Git Repository ‘test-001’

Lastly, for every repositories I create in the future, will I have to clone them all.

Perhaps because Git Cloning downloads quite a few essential files necessary for updates

There are other methods of creating local and remote Git Repositories which you could try. I prefer this method which works for me :slight_smile:

@John_Betong, what is all this jumping through hoops? It sounds like your just not using GIT correctly. There is too much to GIT to even think about talking about how to use it here but there are plenty of tutorials out there. Here is a good starting point…

1 Like

Thank you, that was helpful @John_Betong

I will check it out thanks

You’re right about “not using GIT correctly”. Git and Github are remarkably complicated and have so many features which I have never used since registering a couple of years ago.

As far as I’m concerned, “In Github we trust” - because it caters for every eventuality to ensure the source does not get corrupt.

Rather than wade through the documentation to find how to recover the OP’s problem… I find it easier to clone the repository and copy and paste the old localhost problematic source files.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.