Git will now include your name and email when you publish changes!
Creating a Repository in GitHub
Navigate to github.com, log in, and click the plus button in the top right corner
Creating a Repository in GitHub
Navigate to github.com, log in, and click the plus button in the top right corner
Select the repository owner, yourself!
The owner’s name will appear in the URL of the repository:
github.com/jmwingenroth/repository-name
Creating a Repository in GitHub
Navigate to github.com, log in, and click the plus button in the top right corner
Select the repository owner, yourself!
Choose a repository name.
We recommend choosing something concise and descriptive, all lowercase, with dashes separating words, like my-repo-name.
Creating a Repository in GitHub
Navigate to github.com, log in, and click the plus button in the top right corner
Select the repository owner, yourself!
Choose a repository name.
Choose whether the repository is to be public or private.
Generally, choose private for repositories that will contain sensitive information, and public if the project requires it to be public. For today, choose private.
Creating a Repository in GitHub
Navigate to github.com, log in, and click the plus button in the top right corner
Select the repository owner, yourself!
Choose a repository name.
Choose whether the repository is to be public or private.
Check the box to add a README file.
We will use this to store documentation for the repository.
Creating a Repository in GitHub
Navigate to github.com, log in, and click the plus button in the top right corner
Select the repository owner, yourself!
Choose a repository name.
Choose whether the repository is to be public or private.
Check the box to add a README file.
Choose a .gitignore template from the dropdown menu.
Select the .gitignore template for the programming language you will be using. Any language works for today.
Creating a Repository in GitHub
Navigate to github.com, log in, and click the plus button in the top right corner
Select the repository owner, yourself!
Choose a repository name.
Choose whether the repository is to be public or private.
Check the box to add a README file.
Choose a .gitignore template from the dropdown menu.
Click the “Create Repository” button!!
Cloning Your First Repository With Git
Cloning = making a copy of a repository on your computer
Cloning Your First Repository With Git
Copy the repository URL to the clipboard.
From the repository home page, click the green button, then copy the URL to clipboard by clicking the logo with intersecting squares.
Cloning Your First Repository With Git
Copy the repository URL to the clipboard.
From the repository home page, click the green button, then copy the URL to clipboard by clicking the logo with intersecting squares.
Cloning Your First Repository With Git
Copy the repository URL to the clipboard.
Create a folder called “repos”
Open File Explorer, navigate to the folder where you’d like to store your code, create a folder named repos, and copy the file path using the right-click menu.
Then, navigate there using the cd command in Git Bash:
cd C:/Users/Jordan/repos
Cloning Your First Repository With Git
Copy the repository URL to the clipboard.
Choose where to store the git repository and navigate there.
Enter the git clone <repo-url> command in Git Bash.
In the Git bash window, type git clone then paste in the repository URL from your clipboard by right-clicking:
After cloning, navigate into your repository folder:
cd<repository-name>
Now let’s check the status of our repository:
$ git statusOn branch mainYour branch is up to date with 'origin/main'.nothing to commit, working tree clean
This tells us we’re on the main branch and everything is up to date!
Making Changes
Let’s make a change to the README.md file. Open it in a text editor and add some content:
# My First RepositoryThis is my first Git repository for learning version control!
Now let’s see what Git thinks about our changes:
$ git statusOn branch mainYour branch is up to date with 'origin/main'.Changes not staged for commit:(use"git add <file>..." to update what will be committed)(use"git restore <file>..." to discard changes in working directory)modified: README.md
Viewing Changes with git diff
To see the specific changes you made, use git diff:
$ git diffdiff--git a/README.md b/README.mdindex e69de29..9f4d96d 100644--- a/README.md+++ b/README.md@@-0,0 +1,2 @@# My First Repository++This is my first Git repository for learning version control!
The output shows lines added (in green with +) and lines removed (in red with -), as well as the unchanged title line that GitHub added automatically.
Staging Changes with git add
Git detected our changes! Now we need to stage them before committing:
$ git add README.md
Let’s check the status again:
$ git statusOn branch mainYour branch is up to date with 'origin/main'.Changes to be committed:(use"git restore --staged <file>..." to unstage)modified: README.md
Our changes are now staged and ready to commit!
Creating a Commit with git commit
Now let’s create a commit with a descriptive message:
$ git commit -m"Add description to README file"[main a1b2c3d] Add description to README file1 file changed, 2 insertions(+)
Let’s check our status again:
$ git statusOn branch mainYour branch is ahead of 'origin/main' by 1 commit.(use"git push" to publish your local commits)nothing to commit, working tree clean
Creating a Commit with git commit
Sharing Changes with git push
Our local repository now has changes that aren’t on GitHub yet. Let’s push them:
$ git push
Sharing Changes with git push
Our local repository now has changes that aren’t on GitHub yet. Let’s push them:
$ git pushEnumerating objects: 5, done.Counting objects: 100% (5/5), done.Delta compression using up to 10 threadsCompressing objects: 100% (2/2), done.Writing objects: 100% (3/3), 314 bytes |314.00 KiB/s, done.Total 3 (delta 0), reused 0 (delta 0), pack-reused 0To https://github.com/jmwingenroth/my-first-repo.git9c99bfd..aa653de main -> main
Sharing Changes with git push
Now let’s check our status one final time:
$ git statusOn branch mainYour branch is up to date with 'origin/main'.nothing to commit, working tree clean
Perfect! Our changes are now saved both locally and on GitHub. Open or refresh the repo page in your web browser to see the changes.
Recap
At this point you should have:
✓ Created a repository on GitHub
✓ Cloned it to your local machine
✓ Made changes to files
✓ Staged changes with git add
✓ Committed changes with git commit
✓ Pushed changes to GitHub with git push
✓ Given yourself a pat on the back! 🎉
Next Steps
At the next workshop, we will focus on creating and managing branches and pull requests, which are key to collaborating with other team members on GitHub.