Everything I Keep Forgetting about GitHub
Git is a revision control system, a tool to manage your source code history.
GitHub is a hosting service for Git repositories.
First, see if your computer already has Git, and if so, what version you have.
To do this, go to a Command Prompt and enter:
If you have Git, the response will be something like this:
git version 2.22.0.windows.1
If you don’t have Git, the response will be:
‘git’ is not recognized as an internal or external command, operable program, or batch file.
After installing, configure Git with your username and email, which will be used to identify you later.
git config –global user.name “Your Name”
git config –global user.email “email@example.com”
Here is the “Git Pro” book with everything about it: https://git-scm.com/book/en/v2
There are videos here: https://git-scm.com/videos
Esc, :wq, <enter>
Git opens the Vim editor.
Type the subject of your commit on the first line. Remember to keep it short (not more than 50 characters). Leave a blank line after.
Write a detailed description of what happened in the committed change. Use multiple paragraphs and bullet points to give a detailed breakdown. Don’t write everything out on one line, instead, wrap text at 72 characters.
Esc and then type
:wq to save and exit.
You could also use “-m” when you commit your changes and just type a quick comment on the command line, rather than going into the editor.
git commit -m “comment text”
This process involves VisualStudio, Windows File Explorer, a Web browser, and a Powershell window.
It takes the code files you have stored on your computer, puts them into a local repo, and then uploads the contents of the local repo to a GitHub.com repo.
When you are done coding with VisualStudio and you have saved all of the files, right-click the solution and choose “Open Folder in File Explorer.”
The solution’s folder opens.
Leave the File Explorer folder open, go back into VisualStudio, and close the solution.
Open a Web browser and log into your GitHub account.
Go to your Repositories tab.
Give the repo a name, make sure Public is selected, and check the box to add a README file.
Click the Add .gitignore dropdown and select VisualStudio.
Click Create repository.
Success looks like this…
Click the Clone or download button.
Click the HTTPS link on the dropdown to go to the Clone with HTTPS drop-down.
Select the link and copy it.
Go to a PowerShell window and navigate to the directory where you want to create your local git repo.
You can use the mkdir command to make the directory like this:
After creating the directory, use the cd command to go into it.
Initialize it as a git repo by entering git clone and then pasting the link you copied from GitHub.com.
Your PowerShell command line should look something like this:
You should get something like this:
CD into the cloned repo…
Use git status to make sure everything is okay.
Copy and paste the files from VisualStudio into the local repo.
Go back into PowerShell and look at the contents of the repo.
Run git status to check everything again.
Run git add * to tell git that you want to upload all of the files.
Run git commit -m “comment text” to stage the files for uploading.
Run git push to send all of the staged files to the online repo.
Go back to GitHub.com and refresh the repo page to see all of your local files in the online repo.
That’s okay. Go here: https://github.com/github/VisualStudio/blob/master/.gitignore
Copy the contents of the file.
Go back to your repo, click “Create New File,” and name it: VisualStudio.gitignore
Paste the contents into this new file and save it.