Command line to GitHub: getting grounding - github

I'm new to coding and am getting my grounds still.
I'm working on using the command line to upload to GitHub. I know how to check my status, but how do I see the path of where the repository that is being uploaded is based to make sure the path is correct?

You have to check the origin of the git repository.
git remote -v
This will show you the remote origins you have configured. If you have more origins it'll show them all

Related

how to do "git clone" on VS code

Today, I am following this video https://www.youtube.com/watch?v=RGOj5yH7evk to learn how to use GitHub, but I am using Windows.
I've set it all successfully by also following the official instruction (https://docs.github.com/en/authentication/connecting-to-github-with-ssh/about-ssh) and it works on Git Bash.
enter image description here
But I failed when I tried to "git clone" in Visual Studio Code and got this response:
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
I've also tried setting the config because the video mentioned config (although the official instructions does't mention this, which means Windows users don't need to care about this. But this was what I tried to solve the problem, just in case this could make influence on my problem)
file:C:/Users/CC2022/.gitconfig user.name=CC
file:C:/Users/CC2022/.gitconfig user.email=username#email.com
file:C:/Users/CC2022/.gitconfig core.editor='C:\Users\CC2022\AppData\Local\Programs\Microsoft VS Code/Code.exe' -multiInst -notabbar -nosession -noPlugin
So, is there any requirement for the folder I select to open in VS code to do the git stuff or where is the problem?
Thank you for your help
I can git clone by the HTTP link on both VS code and GitBash, or git clone by the SSH link on Git Bash.
But I have a problem (git clone by SSH link) on VS Code.
In addition, although git clone by HTTP link on VS Code is okay, but I cannot "push" edited files back to GitHub, because the access is denied
That means the repository you are trying to push back to is not one you own/have created. You might therefore have no right to contribute back to it directly.

Used Github Desktop and now terminal not detecting changes

I used Github Desktop to perform a complex merge and now I've noticed that my terminal is not picking up any changes when I run:
git status
I need to first push the code up to origin using Github Desktop, then pull down in my terminal in order for the changes to take place.
Has anyone seen this before?
It appears that github desktop somehow made a clone of the repo in a new location which is why my terminal wasn't locating the file changes. The github desktop repo was located at: /Users/NAME/Documents/GitHub/repo-name. I'm sure this is something I screwed up during setup but figured I'd throw this out there in case it helps anyone!

'git' is not recognized as an internal or external command [Windows]

Not a duplicate of
'git' is not recognized as an internal or external command
I've set up my github repository, downloaded Github Desktop, but I can't figure out how to upload files to the repo.
Here are Github's instructions for me
I've done the "quick set up", and have set up github Desktop on my computer. However, I can't get the command line repo setup to work. Whenever I type out a git command, it gives the above error. I've tried to research why this happens, but the only relevant source (linked above) gave instructions regarding a past version of the github app.
I know this is probably very simple, but I'm quite new and can't find out what to do. Any help is appreciated.
If somehow the GitHub Destop did not add an internal Git to your PATH, you can do so manually with the latest Git for Windows release.
Uncompress the archive PortableGit-2.15.0-64-bit.7z.exe anywhere you want and add it to your PATH (as I do here), then launch GitHub Desktop.

Change upstream of local (hg-git) clone from (github) original to fork

I discovered an OSS project I've contributed to had moved to github. I installed hg-git and cloned a local repo from the git:// URL; then I made changes.
I then realized I really wanted my own github fork, so I made one; but I haven't been able to figure out quite how to switch my existing local repo. I've changed the local repo settings to use the git:// URL of my fork, and it can pull; but I can't push my changes up. It tells me to use the https:// URL, but when I make that change, I can neither pull nor push -- I get an error 406, "not acceptable."
The work done in the local repo is minimal, so I can redo it, but it'd be simpler if the local repo and my fork could just connect now.
UPDATE
I've installed Github for Windows so I could manage the SSH key. It generated a key (github_rsa) and attached it to my Github account.
I edited the hgrc file and added a [ui]ssh= setting pointing to the local git 'ssh' command (buried down in %APPDATA%\Local\Github).
With this, if I go into a "git-shell" window, which I guess spawns ssh-agent, then I can enter commands such as "hg incoming" and the connection is made. So I've got the remote repo URL right, and within the git-shell ecosystem, I've got the SSH keys set up right.
From a regular CMD.EXE window, the same command yields "Permission denied (publickey)". From TortoiseHg, the same error appears when I try an "incoming" action. I'd prefer to keep using TortoiseHg, but I'm not sure how to get it to use SSH.
FINAL UPDATE
For some reason, TortoisePlink doesn't want to play with github's SSH server, at least not with the Github-for-Windows-generated key. So I still have Github for Windows installed (not necessarily a bad thing, but superfluous to what I wanted to do).
To get hg and TortoiseHg to connect, I had to modify my project settings:
[ui]
ssh = %USERPROFILE%\AppData\Local\GitHub\<salt>\bin\ssh -i %USERPROFILE%\.ssh\github_rsa
That is: point to the SSH command, installed with portable GitHub, and specify the github-generated key on the command line. With this configuration, I don't need ssh-agent to be running.
You need to push via ssh, meaning you need to push via:
hg push git+ssh://git#github.com/<login>/<repo>
Note the usage of git# instead of your login in the first part of the URL. This actually matters; the server will figure out your credentials via the supplied SSH key.
You may also have to add your ssh key to your GitHub account first (per step 4 of this page).
This assumes that you created a fork of the original GitHub repository via the GitHub UI; pushing to an empty repository with hg-git may require additional steps.

github - attempting to push/pull/update (not sure of the terminology) updated code from github to remote server via terminal/ssh mac os

So I have my local computer - where I've updated my (html/js/css) code, github (where I've pushed the updated code already by doing a git add + git commit + git push origin master) and then the server of the actual website which the code is for.
I've connected to the server via the command line terminal. I've already previously cloned the code to the server (by running the command git clone [REPO URL]) while logged in to the server via SSH, so the (un-updated-)files are there.
But now that I've updated the code, and pushed that update to github, how do I now update or push the repo/code/updated-github-code to the server???
I'm currently looking at the terminal with
[~]#
^ showing. I tried to git clone [REPO URL] again, but then I get the msg:
fatal: destination path 'name of my file' already exists and is not an empty directory
Am I missing or overlooking a step? Well obviously I am but I could use some help please. Like I said I'm trying to update the code to the server so the actual website will reflect the changes I made to the code and so everything is in sync (local code, code pushed to github and hopefully/eventually the code on the server/website).
I am just learning this obviously, so go easy on me (I've spent almost the entire day learning to connect to the server via SSH in terminal)...
Also, feel free to correct my terminology...
Pull from github while ssh'd into the server using the link from the github repo "copy to clipboard" button on the web interface. If that doesn't work you could try wiping the repos folder on the server and cloning from scratch. But use that option with caution if downtime is unacceptable for this particular web app.