- Git is a tool to track changes in files
- It helps you:
- Save your work (history)
- Work in branches
- Share changes with others
-
See what changed:
git status
-
View file changes:
git diff
-
Pick what goes into the commit:
git add .
-
Or add one file:
git add docs/git-basics.md
-
Save a snapshot with a message:
git commit -m "Explain git add and commit"
-
A branch is your own “work lane”
-
Create a branch:
git checkout -b my-branch-name
-
Switch back to main:
git checkout main
-
First push for a new branch:
git push -u origin my-branch-name
-
If upstream is set:
git pull
- git status
- Edit a file
- git add .
- git commit -m "Update instructions"
- git push
- “Nothing to commit”
- You forgot git add
- “Rejected / failed to push”
- Your branch is behind
- Try git pull then push again
- Read: How to Commit
- Then: How to Push