Having trouble pushing to GitHub


#1

Created a repository in GitHub, copied its url and pasted in config file. Git folder appears in the folder in which the file I am trying to push (trial.md) to GitHub. Was seeing yellow and green but not anymore. If i stage the file, I see a “detach commit message”. Doesn’t commit. Says no origin or something. I pasted the url into the config file. Don’t know what to do. Please help!!!


#2

I want to be able to use Atom’s GUI to push and pull from GH, not go to the command line (I assume this is the GitBash feature?). I tried the Ctrl-Shift-P command and GitHub: Clone, pasted the url from the repository I had created in GH, had to create a folder with the SAME name as this repo in another directory and then cloned that repo to this directory. Seems like such a small thing but I kept thinking GH or Atom would clone that repo from GH into my computer and create the folder. This fellow Herlangga SW shows the same folder and repo names in his YouTube video, “ATOM - How To Setup GitHub and Git From Atom Editor”. Created many such folders though. Maybe because I kept doing this when I didn’t see immediate results. Atom takes time to sync…? Anyway, I modified my Readme file and pushed it into the repo on GH and modified the file in GH and pulled it into Atom. So this worked. If I have existing files in Atom, can I still push these into GH? I suppose I would create repository with the same name as the one that contains the File? What if it already has .git? Maybe I should just create a new file and copy and paste into it. This Herlangga SW shows how to change config. Seems knowledgeable though seems to be a little out of it with all the smoking etc. Is this necessary (I am referring to the config changes, not the smoking)?


#3

Open the command line and type git remote add origin https://github.com/vidyer/welcome-project-vidhya.

I pasted the url into the config file.

What config file? It might help if you shared a screenshot of it.

I want to be able to use Atom’s GUI to push and pull from GH, not go to the command line

You can do this, but the repo has to be configured correctly first.

Maybe because I kept doing this when I didn’t see immediate results. Atom takes time to sync…?

Yeah, Atom takes time to send the instruction to the external program, wait for the repo to clone (you really should clone a repo from the command line at least once to see what goes on from that side), and display the results once git has reported that it’s done.

I suppose I would create repository with the same name as the one that contains the File?

That’s not necessary. All that’s necessary is that you have the remote repo’s address registered as I have shown you.

This Herlangga SW shows how to change config. Seems knowledgeable though seems to be a little out of it with all the smoking etc. Is this necessary (I am referring to the config changes, not the smoking)?

It would be helpful if you shared what the config changes are.


#4

Here’s the screenshot showing the config file for novtrial repository (folder?); I opened it and typed what he typed, haven’t saved it.


Following a reply in Stackoverflow, I installed the platformio-ide-terminal package and opened the terminal in Atom. I hope this is what you meant by command line. The screenshot also shows the terminal and what you told me to type.
But I have another question: I have three repos in GH and none of them is called welcome-project-vidhya. This is a folder on my desktop that contains the file trial.md that I was trying to modify and push. Shall I create a repo in GH called welcome-project-vidhya?
After typing the line in the terminal and staging trial.md in that welcome-pro… folder, there is no Fetch and I am unable to Push this file after typing the line in the terminal.
Now what do I do?


#5

This is how that part of the config file should look:

You need to change line 1 to remote "origin". I think it will work after that. This is one reason why you should avoid editing .git/config directly. Using git commands on the command line is enough and will make sure that everything is formatted correctly.

Or your system command line, or git bash, according to your preference. It really doesn’t matter which one you use as long as the git executable is somewhere that your chosen software can see it.

The screenshot also shows the terminal and what you told me to type.
But I have another question: I have three repos in GH and none of them is called welcome-project-vidhya.

Then why did you type that? At no point did you tell me what your repo was called, so I had to make something up to show you the format of the URL. But you know the name of your repo, and I just told you that it’s absolutely unnecessary for the GitHub repo to have the same name as your local folder, so I think you can answer your next question.


#6

But I have another question: I have three repos in GH and none of them is called welcome-project-vidhya.

Then why did you type that?
Because you told me to!
Anyway, sorry for irritating you with my inane questions. Here’s what happened after I read your reply:
I tried typing the git command again this time to hello-world, got a fatal error message.
I went to GH and changed the name of the repo from hello-world to welcome-project-vidhya.
I tried changing the config file.
image
Was able to see the orange color when I changed trial.md in welcome-project-folder but after staging and committing to master, could only see Publish not Fetch and when I clicked on that, it did say Pushing 1 file but then I got this error message.
image
Again and again.
By that time, I scrolled down in Tree view and saw that another welcome-project-folder had been created. That git .config file didn’t look like the one I typed at all.
I cloned the welcome-project-vidhya repo again and did that GitHub: Clone thing again and tried to modify readme.md. This time, I saw the orange and green colors on staging and committed the file and pushed it. Saw it in GH.
So I copied and pasted trial.md from the upper w-p-v folder to the lower w-p-v folder with the modified and pushed readme.md file and made a small change to it, committed it and pushed. It came through in GH.
image
So some more questions:

  1. Is it not possible to undo the git command once you assign a repo as the origin/remote or whatever you call it?
  2. All these changes to the config file: are they necessary?
  3. I got a sign-in popup box last night, today, couldn’t see that. But I did update Atom to 1.33 today–would that have influenced some of the outcomes?
    I plan to take the Git and GitHub tutorials course again (I mean watch and practise them) as I am still unclear as to what is going on with all these commands. Any advice on anything else I could do to be less clueless around all these things?

#7

I had typed in around Because you told me to! but I think it removed it! Must have thought it was code for something!
Anyway, DamnedScholar, thanks for your patience and help.


#8

If you always follow directions to the letter instead of looking for where you need to fill in your own knowledge, then you definitely need to get in the practice of laying all of your knowledge on the table at the beginning.

I tried changing the config file.

But you don’t always follow directions, because I also told you to not edit that file by yourself, then I showed you how it looks when it’s correct, then you just left out two brackets that were in my screenshot.

Is it not possible to undo the git command once you assign a repo as the origin/remote or whatever you call it?

Yes, of course. You undo the git remote add command with git remote remove. You don’t assign a repo as the remote, you assign a remote repo as the origin. It’s remote because it’s not on your computer, and it’s the origin because, if you cloned it, that’s where it came from.

All these changes to the config file: are they necessary?

No, and if you’ve been following any tutorials that recommend changing the config file, throw them out and look for one that gives you the command line instructions.

I got a sign-in popup box last night, today, couldn’t see that. But I did update Atom to 1.33 today–would that have influenced some of the outcomes?

Doubtful.

I plan to take the Git and GitHub tutorials course again (I mean watch and practise them) as I am still unclear as to what is going on with all these commands. Any advice on anything else I could do to be less clueless around all these things?

I’m the kind of hardcore intellectual masochist that gets satisfaction out of reading the most technical source material in order to understand how things work, so I just taught myself off of the official documentation, but a great environment in which to learn about things git-related is GitKraken. It’s a pretty, visual environment that gives you drop-down menus of all the different commands to choose from and helps in visualizing the activity of a busy repository.

Must have thought it was code for something!

It kind of is. :slight_smile:


#9

Made some changes to my Markdown file and tried pushing it. Not able to do it. Tried adding the remote repo again using that command you gave me last time.


Am unable to even stage the file. Followed whatever I wrote down last time and whatever I can remember. Still not working… Help?


#10

So I added the square brackets around line 1 remote “origin” in gitconfig because I think last time you told me I wasn’t following directions when I tried removing them.
Still wasn’t able to do anything. Shut Atom down, restarted, was able to stage the file. But only pull request appeared. Couldn’t do GitHub: Clone. Command palette doesn’t even appear when I press Ctrl Shift P or go to the menu option.
Tried committing. When I didn’t get push arrow, I tried clicking on pull to see if something would work and give some indication about what was happening. Got this message.


I “force pushed” it by Ctrl-clicking it on the push arrow. It came through!
But regardless of these flashes in the pan, I don’t believe I have understood what is really going on here. I understand the process of staging and committing and pushing and pulling. But these modifications and tweaking things don’t always seem to work consistently. Not sure if I can reproduce anything this way. I went back and read documentation. Still not confident of navigating these messages and issues. Can you tell me what’s going wrong here?


#11

I find them very consistent. Every time you mis-edited the config file, you either got a “no valid repo” or “no valid config file” error. When the config file was fixed the first time, you got a “your repository is behind the remote” error because it was. The second time, you got an unrelated histories error because you had done different things to your local and remote repositories (git establishes that the repositories are for the same project by looking at the alphanumeric codes for the previous commits).

Command palette doesn’t even appear when I press Ctrl Shift P or go to the menu option.

What happens when you use the Keybinding Resolver (ctrl-.) and try to open the Command Palette?