top of page

Git & GitHub – Simple Notes

Nov 8

1 min read

0

0

0


Think of Git, it is like a time machine for your code. And GitHub is like an online photo album where you can keep all those time-travel versions and share with friends.

1.  Start Your Project git init

📌 Meaning: Start tracking this folder with Git (make it a Git project).

💡 When to use: At the very beginning, inside your project folder.

✁ Example:

git init

(You’ll now see a hidden folder .git if you run ls -a).



2.  See What’s Inside ls -a

📌 Shows all files, including hidden ones. Useful to check if .git exists.



3.  Check Status git status

📌 Shows which files are new, changed, or ready to be saved (staged).

✁ Example Output: Untracked files:

hello.txt



4.  Add & Commit (Save Changes) git add fileName


📌 Select file(s) you want to save (stage changes).

✁ Example:

git add hello.txt

git commit -m "message"

📌 Take a snapshot of project & write what changed.

✁ Example:

git commit -m "Added hello.txt"

📌 Tip: Always write meaningful commit messages.



5.  View / Edit Files vi fileName

📌 Opens file in terminal for editing.

✁ Example:

vi hello.txt

cat fileName

📌 Displays content of the file in terminal.

✁ Example: cat hello.txt


6.  See History git log

📌 Shows all commits (history).

✁ Example Output: commit a7c3...

Author: You

Message: Added hello.txt


7.  Delete or Undo rm -rf fileName

📌 Delete file permanently from folder.

git reset

📌 Go back to a previous commit (undo).

✁ Example:

git reset --hard HEAD~1

(This removes last commit completely.)



8.  Stash (Temporary Save)

Sometimes you want to hide changes without committing.

git stash

📌 Hide all current changes safely.

git stash pop

📌 Bring those hidden changes back.

git stash clear

📌 Remove all stashed changes forever.



9.  Connect to GitHub

git remote add origin URL

📌 Connect local project to a GitHub repo.

✁ Example:

git remote add origin https://github.com/user/repo.git

git remote -v


📌 Check if connection worked.

git push origin main

📌 Upload local code to GitHub on main branch.



10.  Branching

Branches are like alternate storylines.

git branch

📌 Show all branches.

git checkout branchName

📌 Switch to another branch.

git merge branchName

📌 Merge that branch into current branch.



11.  Work With Others Fork

📌 Copy someone’s GitHub repo into your GitHub.

git clone URL

📌 Download project to your computer.

git remote add upstream URL

📌 Connect back to original project (main repo).

Pull Request

📌 Ask project owner to accept your changes.

git push origin branchName

📌 Upload your changes in a specific branch.


Merge Pull Request

📌 Owner reviews and adds your work to main branch.



12.  Keep Updated git fetch --all --prune

📌 Get all new updates from remote and clean deleted branches.



13.  Merge Conflicts

📌 Happens when two people change the same line. Git will ask you to choose which change to keep.

You fix it manually and commit again.



Summary for Beginners

·        Git = Time Machine for your code

·        GitHub = Online Locker to store & share code

·        Learn to init, add, commit, push → your basic workflow.

·        Use branch & merge → to try new features safely.

·        Use stash & reset → to manage mistakes or hide work.

Nov 8

1 min read

0

0

0

Related Posts

Comments

Share Your ThoughtsBe the first to write a comment.

123-456-7890

500 Terry Francine Street, 6th Floor, San Francisco, CA 94158

Stay Connected

Contact Us

bottom of page