AI Bootcamp
.gitignore| Term | Description |
|---|---|
| Repository (Repo) | A database storing all files and history of changes |
| Commit | A snapshot of the repository at a specific point in time |
| Branch | A separate line of development |
| Merge | Combining changes from different branches |
| Clone | Copying a repository to your local machine |
| Push / Pull | Syncing changes between local and remote repositories |
Step 1 — Install Git:
Download from https://git-scm.com/
Step 2 — Configure your identity:
Navigate to your project directory:
Initialize a new Git repository:
Clone a repository from a URL:
This creates a directory named
repocontaining all the files and history.
Check the status of your files:
This shows which files are staged, unstaged, or untracked.
Add a specific file / multiple files:
Add all files:
Add all files of the same type:
Rename a file:
Move a file to a different directory:
Delete a file from the repository:
Forcefully remove a file:
Forcefully remove a directory and its contents:
⚠️ Use with caution — permanently deletes from your working directory and staging area.
Commit staged changes with a message:
Amend the last commit message:
Full commit history:
Shows a list of commits with their messages, authors, and dates.
Compact one-line view:
A branch is a separate line of development.
Create and switch to a new branch:
Switch to an existing branch:
Modern alternative using git switch:
Merge a branch into the current branch:
Resolve any conflicts that arise after merging.
Delete a branch locally:
Delete a branch on the remote:
Push changes to remote:
Pull changes from remote:
If the main branch is protected, update the default branch in repository settings first.
Conflict markers look like:
<<<<<<< HEAD
your changes
=======
their changes
>>>>>>> branch
Edit the file, remove markers, keep what you need.
Revert a specific file to a previous commit:
Reset the entire repository to a previous commit:
Safely undo a commit (creates new inverse commit):
git revertis preferred — it undoes changes without altering the commit history.
Stash current work-in-progress:
Apply / view / drop stashes:
.gitignore.gitignoreThe .gitignore file tells Git which files or patterns to ignore.
Common uses:
.DS_Store, Thumbs.db)Generate for Python:
Example .gitignore:
# Python
__pycache__/
*.pyc
*.pyo
.env
venv/
# Jupyter
.ipynb_checkpoints/
# OS
.DS_Store
Thumbs.db
# IDE
.vscode/
.idea/
Best Practices:
# 1. Clone the repository
git clone https://github.com/user/repo.git
# 2. Create a feature branch
git switch -c feature-branch
# 3. Make changes and commit
git add .
git commit -m "Add new feature"
# 4. Push branch to remote
git push origin feature-branch
# 5. Open a Pull Request on GitHub → review → merge
# 6. Update your local main
git switch main
git pull origin main| Resource | Link |
|---|---|
| 📘 Git Guide Book | git-scm.com/book |
| 🌿 Learning Branching | learngitbranching.js.org |
| 🔷 Atlassian Git Tutorials | atlassian.com/git |
| 🏫 W3Schools Git | w3schools.com/git |
Tasks:
my-first-repo and initialize Git inside itREADME.md describing the project"Initial commit"git config --global user.name "Your Name"
git config --global user.email "you@email.com"
mkdir my-first-repo && cd my-first-repo
git init
echo "# My First Repo" > README.md
git add README.md
git commit -m "Initial commit"
git remote add origin https://github.com/yourname/my-first-repo.git
git push -u origin mainTasks:
my-first-repo, create a new branch called feature/add-infoinfo.txt with any content and commit itmainfeature/add-info into mainmain to GitHub
Instinct Institute
Mork MongkulIntroduction to Git | AI Bootcamp