- Git can be thought of as a timeline management utility ⏳
- A commit is a snapshot 📸 of what the project looked like when it was saved at a certain point in time.
- Every commit has a SHA
- Every commit has the changes that were made in that commit.
git show
to see those changes.
- Play video games? You're playing your videogame and your character dies, you can always go back to when you last saved the game before your charater died. 🎮👾
- Stands for Secure Hash Algorithm 🔒
- it looks something like,
e2675e151a18082b19f00461e9b581b6b2dd2937
- SHA uniquely identifies a commit
- Why is SHA important? Security and Integrity. We cannot mess around and change a commit.
- nodes with pointers pointing to another node in a direction
- A commit point to their parent commit
-
linked lists are a conceptual data structure
-
Side note: One way to implement a linked list in Javascript is shown here in this article
Linked lists are memory efficient. We can compare them to Arrays. Arrays take up a chunk of fixed space, whereas linked lists are more free flowing and will take up space where there's space available.
Array:
Linked list:
-
A branch pointer to a commit SHA
-
main ------> 2e92da new-feature -----> 23wsdf3 experiment ------> 87d8d8d
-
You can type this in the root of your git repo to see what your master branch points to
-
cat .git/refs/heads/master
Info on how to get out of sticky situations/mistakes made with commits
git pull
- ❗️important: get the latest version of main before you create a branchgit branch
- Lists all your branchesgit branch [branch-name]
Create a new branch at the current commitgit checkout [branch-name]
- Switch to another branchgit checkout -b [branch-name]
- Create and checkout a new branchgit branch -D [branch-name]
- Delete a branch locally
git push
- You may need to add a remote upstream
- upstream is a name for the main repo where you pull and push to
- How to open a PR
- How to do a code review, approve, and merge to main in Github
❗️Important: Before pushing your branch to remote/origin, pull main, and rebase your branch with main. You should do this if origin main has been updated/diverged from your local version of main while you were working on your feature branch. Ask me if you have any questions about this! Have fun! 🥳
Steps to rebase:
-
git checkout main
-
git pull
-
git checkout [branch-name]
-
git rebase main
-
or
git rebase main [branch-name]
-
git push
-
Now your branch should be updated with the latest version of main