Step-by-Step Guide for Beginners: What is Git and How to Use GitHub Desktop with a Text File Example
A simple step by step for those new to Git and using GitHub. What is Git and how to use it to upload and edit a simple text file.
This guide is a simple step by step for those new git Git and using GitHub. I wrote this for my students originally (shout out to you legends, you know who you are).
I decided on GitHub and GitHub Desktop for its popularity and its official (and simple UI) respectively. It does not mean i endorse or support the position of these Apps and services as there exists self-hosted and open source alternatives. In the world of programming and software development, GitHub is the law. Know that and you will fit in anywhere.
1. What is Git?
Git is a distributed version control system that allows you to track changes to your code and collaborate with others. GitHub is a platform that uses Git for hosting and sharing repositories. GitHub Desktop is an application that simplifies using Git and GitHub.
I personally use GitKraken, but its more involved then GitHub Desktop. GitHub Desktop serves well as an introduction to Git and its simpler interface will be an easier pill to swallow. Then when your feeling confident or suicidal you can switch to Kraken.
2. Install GitHub Desktop:
GitHub Desktop is available on Linux (via the AUR), MacOS and Windows.
- Go to the GitHub Desktop website (https://desktop.github.com/).
- Download and install the application on your computer.
3. Create a GitHub Account:
- If you don't already have one, sign up for a GitHub account at https://github.com.
4. Sign in to GitHub Desktop:
- Launch GitHub Desktop.
- Sign in using your GitHub account credentials.
5. Configure Git:
- The first time you run GitHub Desktop, you may be prompted to configure your Git identity.
- Provide your name and email address to link your commits to your GitHub account.
6. Create a New Repository:
- Click on the "File" menu and select "New Repository."
- Choose a name for your repository.
- Choose a local path on your computer to save the repository.
- Set the repository to be public or private (you can change this later on GitHub's website).
7. Initialise Repository:
- Click the "Initialise with a README" option if you want to create a README file for your project.
- Click "Create Repository" to create the local repository.
8. Create or Add a Text File:
- In the local repository on your computer, create or add a text file (e.g., "example.txt") in the project folder.
9. Commit Changes:
- Open GitHub Desktop.
- You'll see your changes in the "Changes" tab.
- Enter a brief summary in the "Summary" field.
- Optionally, provide a description in the "Description" field.
- Click the "Commit to main" button to commit your changes to the local repository.
10. Publish to GitHub:
- To share your repository on GitHub, click the "Publish repository" button.
- Choose your repository name and repository visibility (public or private).
- Click "Publish repository."
11. Update the Text File:
- Make changes to the "example.txt" file on your computer.
12. Commit and Push Changes:
- Open GitHub Desktop.
- In the "Changes" tab, you'll see the changes in the text file.
- Enter a summary and description for the changes.
- Click the "Commit to main" button to commit the changes to your local repository.
- Click the "Push origin" button to push the changes to your GitHub repository.
13. View Changes on GitHub:
- Open your GitHub repository on the GitHub website.
- You'll see the updated "example.txt" file in your repository.
Congratulations! You've successfully set up a Git repository, added and updated a text file, and shared your project on GitHub using GitHub Desktop. This is just the beginning of your Git and GitHub journey, and there's much more to explore as you become more comfortable with these tools.
This may seem like a lot to do for a simple text file. But in context of hundreds or thousands of code files, this small setup allows for the seamless transfer, versioning and cross person communication of files that would be a nightmare without it.
What next?
Well, the next simple project you could do is a GitHub profile. It may seem simple, but you have to start somewhere. Follow my in-depth guide here
Click the image to see my profile.
The front pages of profiles and all repositories using a standard README.md file. If you have one of these files in any project, the contents of that file is displayed on the front page in GitHub. (highlighted file in the repo is the README.md)
Images:
Header Image by Markus Winkler from Pixabay