The first time you open a terminal to use Git, the hardest part can be knowing what to type next. Start with one small change. By the time you’ve reviewed it, committed it, and opened a pull request, you’ll have practiced the workflow you’ll use on a team.
Git records changes to files in a repository. GitHub hosts Git repositories and gives teams a place to review changes, run checks, and discuss work. You can practice the first section entirely on your own computer.
1. Start a repository and make your first commit
Use git clone when you’re starting from an existing repository. For a new local project, run git init -b main from the project folder. Configure the name and email you want recorded in your commits before making your first one.
After you edit a file, run git status -sb to see what changed and git diff to inspect unstaged edits to tracked files. Stage the file you intend to commit, then run git diff --staged to see exactly what the next commit will record. That last check can catch an unrelated edit or a local configuration file before it gets into history. A commit stays local until you share it, typically with git push.

2. Use branches and pull requests to work with a team
For a team change, start from an up-to-date base branch and create a branch for one focused task. Make and test your change, commit it, and push the branch. Open a pull request on GitHub so reviewers can see what changed, why you changed it, and how you tested it. Follow the repository’s review and status-check requirements before merging.
If a merge conflict appears, use git status to find the affected files. Read both versions before deciding what to keep, then test the result before finishing the merge. If you’re contributing to a project where you lack write access, the reference page also shows where a fork fits into the workflow.

3. Choose the right way to undo a change
Start by asking where the change is. To unstage a file while keeping your edits, use git restore --staged with the file path. To reverse a commit that teammates already have, git revert creates a new commit that undoes the selected change. Check before running git reset --hard, which can discard local edits. Treat a force push as a coordinated exception because it can replace branch history that others are using.
Add local artifacts to .gitignore before staging them. Ignore rules apply to untracked files and leave existing commits intact. Checking the staged diff before every commit is a simple way to catch mistakes early.

Git and GitHub Whiteboard Walkthrough
This eight-slide companion follows the guide from your first commit to a team pull request. Review the steps on your own or walk through them in a classroom or team session.
Explore my GitHub projects
Want to see how a small project is organized on GitHub? Open my uConsole CM4 Charging Boost repository. Start with the README to see how the project is documented, then browse the files and commit history to see how it evolved.
Follow me on GitHub for more hands-on Linux and uConsole projects.
For command options and workflow details, see the Git command reference and GitHub flow.


Leave a Reply