A friendly, hands-on introduction to Git for people who don't write code. Use Git to keep track of changes to documents, plans, spreadsheets, and other files—and to recover or collaborate with confidence.
You will learn to: save checkpoints, see what changed, try a separate version, and share work. No programming experience is needed.
- Git is a tool on your computer that records changes to files.
- GitHub is a website where you can store Git projects and work with other people. You can learn the Git basics without a GitHub account.
Think of Git as a history-aware folder. Unlike repeatedly saving files as plan-final-v2-really-final.docx, Git keeps named checkpoints in one project.
Git gives you a chance to review changes before saving a checkpoint:
Your project folder Staging area Saved history
┌──────────────────┐ ┌─────────────────┐ ┌───────────────┐
│ Edit and create │ ────▶ │ Choose changes │ ───▶ │ Commit: save │
│ files here │ add │ for next save │ save │ a checkpoint │
└──────────────────┘ └─────────────────┘ └───────────────┘
In Git, a saved checkpoint is called a commit. You can make one whenever you reach a useful stopping point.
This example uses a terminal (also called a command line), a text-based way to give your computer instructions. Copy one command at a time. Replace the example folder name if you like.
mkdir weekend-plan
cd weekend-plan
git init -b maingit init -b main starts tracking this folder and names the first branch main. It does not upload anything.
Open a text editor, write a short plan, and save it in the weekend-plan folder as plan.txt. For example:
Weekend plan
- Visit the farmers market
- Have a picnic
git statusGit will show that plan.txt is new. Now tell Git to include it in your next checkpoint:
git add plan.txt
git statusThe file is staged: selected for the next checkpoint. Staging is like putting selected papers in an envelope before sealing it.
git commit -m "Add first weekend plan"The message in quotation marks is a short note to your future self about what this checkpoint contains.
Edit plan.txt to add - Bring a blanket, then run:
git status
git diff
git add plan.txt
git commit -m "Add picnic reminder"
git log --onelinegit diff previews what changed. git log --oneline shows your saved checkpoints, newest first.
Your project now has a history:
oldest newest
● Add first weekend plan ───▶ ● Add picnic reminder
checkpoint 1 checkpoint 2
A branch is a separate line of work. It lets you experiment without changing the version you consider your main one.
git switch -c rainy-dayNow edit plan.txt to add a rainy-day activity, and save that change:
git add plan.txt
git commit -m "Add rainy-day activity"Switch back to the original branch with:
git switch mainThe rainy-day change is still saved on its branch; it has not been added to main. Branches are useful for trying options, not just for software.
● Rainy-day activity (rainy-day)
/
● First plan ───▶ ● Picnic reminder (main)
If you are using an existing project, its original branch may be called master. Use that name instead of main throughout this guide. Run git branch to list the branches; the star marks the current one.
A merge brings changes from another branch into the branch you are currently on. When you are happy with the rainy-day idea, bring it into main:
git status
git switch main
git merge rainy-day
git statusBefore switching or merging, make sure git status reports a clean working tree. If it does not, finish and commit your changes first.
Open plan.txt: the rainy-day activity is now part of main. The direction matters: switching to main before running git merge rainy-day brings the changes into main. It does not delete the rainy-day branch.
In this example, main has not changed since you created rainy-day, so Git can simply move main forward. Git calls this a fast-forward merge. If both branches have new commits and their changes can be combined automatically, Git creates a merge commit instead. If an editor opens for its message, save and close it to finish.
Check the combined history with:
git log --oneline --graph --allChanges on main do not always cause a conflict. A merge conflict happens when Git cannot automatically combine changes, such as when two branches edit the same line differently. Git pauses the merge so you can choose the final text.
Try this after merging rainy-day. On main, add this line to plan.txt:
- Activity: visit the park
Save it, commit it, and create another branch:
git add plan.txt
git commit -m "Add activity choice"
git switch -c museum-planOn museum-plan, change that line to - Activity: visit the museum, save the file, and commit:
git add plan.txt
git commit -m "Choose the museum"
git switch mainBack on main, change the same line to - Activity: visit the beach, save the file, and commit. Then try the merge:
git add plan.txt
git commit -m "Choose the beach"
git merge museum-plan
git statusGit reports a conflict in plan.txt. Open it in your text editor and find:
<<<<<<< HEAD
- Activity: visit the beach
=======
- Activity: visit the museum
>>>>>>> museum-plan
The text above ======= is from your current branch (HEAD, here main). The text below it is from the branch you are merging (museum-plan).
Choose either version or combine them. Replace the whole marked block, including all three marker lines, with the text you want, for example:
- Activity: visit the beach, then the museum
Save the file, then mark it resolved and finish the merge:
git add plan.txt
git diff --cached
git commit -m "Merge museum plan and settle activity choice"
git statusgit add tells Git you have resolved this file; git diff --cached lets you review the staged result. If Git lists other conflicted files, resolve and stage each one before committing. After the commit, git status should report a clean working tree. Open plan.txt to check the final plan.
To cancel instead, run git merge --abort before completing the merge commit. This returns you to the state before the merge attempt when you started with a clean working tree. Your branch commits are still saved, so you can try again later.
Git can track a project on your computer without an internet connection. To share it, connect your local repository to another repository, such as one hosted on GitHub. Git calls that connection a remote.
origin is the conventional nickname for your project's main remote. It is not a branch or a special GitHub command: it is a local name for a repository address. main names a branch; origin names a remote.
Create an empty repository named weekend-plan on GitHub. Do not initialize it with a README, license, or .gitignore, because your local project already has its own history. Replace YOUR-USERNAME below with your GitHub username:
git remote add origin https://github.com/YOUR-USERNAME/weekend-plan.git
git remote -vgit remote add saves the connection; it does not upload files. git remote -v shows the addresses used to receive changes (fetch) and send them (push).
If origin already exists, inspect it with git remote -v instead of adding it again. If its address is wrong, correct it with git remote set-url origin https://github.com/YOUR-USERNAME/weekend-plan.git. Projects downloaded with git clone normally already have an origin remote.
git push sends your local commits to a remote repository. Publish main for the first time with:
git status
git switch main
git push -u origin mainStart with a clean working tree. This sends your local main branch to origin. The -u option remembers the matching remote branch as its upstream, so later pushes from main can simply use git push. Open your repository on GitHub to check that the plan is there.
Pushing sends commits, not unsaved edits or changes you have only staged. You need permission to write to the GitHub repository and may need to sign in using your GitHub tools. Never put a password or access token in the remote URL.
git pull downloads changes from the remote and integrates them into your current branch. It does not just download files. After the first push above, update your local main with:
git status
git switch main
git pull --ff-onlyCommit any unfinished work before pulling. The upstream set earlier tells Git to use origin and its main branch. --ff-only allows the update only when Git can move your branch forward without combining separate lines of work.
If both you and someone else have made new commits, git pull --ff-only stops without merging them. It has still downloaded the remote history. To combine those changes, run:
git merge origin/mainorigin/main is your local record of main on origin, updated when Git downloads changes. If this merge reports conflicts, follow the conflict-resolution steps above, then push once the merge is complete. If an editor opens for a merge message, save and close it to finish.
A typical routine on main, once the remote and upstream are set, is:
- Run
git pull --ff-onlyto get the latest work before editing. - Edit your files, review with
git diff, then stage and commit your changes. - Run
git pushto share your commits.
If a push is rejected because the remote has newer commits, pull again, combine any separate histories as described above, and retry the push. Do not use git push --force to bypass this: it can overwrite other people's shared history.
Try these in your weekend-plan folder. Use git status whenever you are unsure what Git sees.
- Make a checkpoint: Add a favorite snack to
plan.txt, stage the file, and commit it with a message. Check that the new checkpoint appears ingit log --oneline. - Inspect a change: Add one more line but do not stage it yet. Run
git diffand identify the line you added. Then stage and commit it. - Try a branch: Create a branch called
birthday-idea, add a birthday activity, and commit it. Switch back tomain(ormaster) and check that the birthday activity is not in that version. - Merge a branch: Merge
birthday-ideainto your original branch. Check that the birthday activity is now inplan.txtand thatgit statusreports a clean working tree. - Resolve a conflict: Repeat the conflict walkthrough above with a new branch called
snack-planand a line for your snack choice. Commit different changes to that same line on both branches, merge into your original branch, and resolve the conflict. Check the final text and working-tree status. - Explain the diagram: In your own words, describe the difference between a project folder, the staging area, and a commit.
git statustells you what is new, changed, or staged.git add plan.txtselectsplan.txtfor the next commit; it does not save a commit by itself.git commitsaves the staged changes in your local history.- A branch lets you keep a separate version of work.
git merge rainy-daybrings changes fromrainy-dayinto your current branch.- A merge conflict pauses a merge until you choose the final content, stage each resolved file, and commit.
originis a remote nickname;mainis a branch name.git push -u origin mainpublishesmainand sets its upstream for later pushes and pulls.git pushsends commits;git pulldownloads and integrates remote changes. Neither is needed for local practice.
- Make commits small enough that their messages can describe them clearly.
- Run
git statusbefore and after staging or committing. - Git records changes to files, not every action you take. A change must be staged and committed before it is in the saved history.
- Avoid putting passwords or private information in files you plan to share.