repositories issues

Hi all,

I’m new with Git and GitHub, then I’m trying to initialize everything and start using it.

I installed Git because I want to keep track of changes I do on my code and get back to a previous version in case it is needed.

Hence, I made a “git init” from the command line into the directory where my files are stored and a new folder .git appeared (I can see it from ls -la). I begun to track my files, made changes, committed them and everything was ok.

Today, I created a new repo (just for safety, in case of  pc breakdown) on gitHub and I added it from the command line as “git remote add (name) URL” and I tried to add all the documents I’m working on by “git push (name) master” . It didn’t work and a warning message appeared, so I made a fetch on the same repo and then again a push and this was the result

Utente@ASLM MI----------------------------------------------------------- (master)
$ git push -u bitbuc master
To https://------------------------------------------
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘https://--------------------------------------------’
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push --help’ for details.

What should I do? Why should I make a pull if the remote repo is empty? I’m scared it erases everything in my local folder…

Please help me :frowning:

Thanks in advance for your time! :slight_smile: (I’m new with this kind of stuff then I ignore a lot of things XD)

Kind regards,

Noemi

1 Like

Hi @noemibarba93,

Thank you for being here! It appears that the origin was not set properly. If you are trying to set your remotes, you would have to run a command like this in git:

git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git

Adding the repository to the upstream will set it so that you can upload changes to GitHub. To verifiy that this has been done correctly, check by using:

git remote -v

This will show you all of your remotes for fetch and pull so that next time you run git push origin master it should go through.

1 Like