Everything I Keep Forgetting about GitHub

 

 

Contents

1.       GitHub and Git are not the exact same thing. 1

2.       Git - Where do I start?. 1

3.       Git - What are the basic commands?. 2

4.       Git – How do I save a git commit message and get out of the editor?. 2

5.       GitHub - How to upload a VisualStudio solution to a Github repository. 2

6.       Oh no! I forgot to add a VisualStudio .gitignore file when I created my new repo on GitHub. 11

 

 

 

1.   GitHub and Git are not the exact same thing

Git is a revision control system, a tool to manage your source code history. 

GitHub is a hosting service for Git repositories.

Git is the tool. GitHub is the service for projects that use Git.

Source: Difference between Git and GitHub - Stack Overflow https://stackoverflow.com/questions/13321556/difference-between-git-and-github

 

2.   Git - Where do I start?

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:

git version

 

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.

 

Download Git here: https://git-scm.com/  or here: https://gitforwindows.org/

 

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 “your.name@codesmartinc.com”

3.   Git - What are the basic commands?

git help

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

4.   Git – How do I save a git commit message and get out of the editor?

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.

Press 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”

5.   GitHub - How to upload a VisualStudio solution to a Github repository

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.

Click New.

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:

Press enter.

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.

 

Before…

 

After…

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.

 


 

6.   Oh no! I forgot to add a VisualStudio .gitignore file when I created my new repo on GitHub

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.