Default Flashcards
What are annotated tags and what is the function?
Label that shows the state of the project.
git tag -a -m “I love cheesecake”
How to copy and paste in git bash console?
CTRL + Insert (copy) | SHIFT + Insert (paste)
Command to turn a folder into a GIT repository
git init
after complete try:
ls -a
to show subdirectories (-a for the hidden ones)
What does SHA-1 mean?
A 40 character revision identifier that is used in git. It is (almost unique) - meaning no oher input data should ever produce the same hash. However, the same input data should always produce exactly the same hash.
Every object that is processed by the git repository has a unique SHA-1, which allows us to control versions.
What are the objects in git?
Blobs
Trees
Commits
Annotated Tags
How to add files to git repository?
git add recipes/apple_pie.txt
git status
git commit -m “Recipe Added”
Concept of GIT as a map
Git is a map where the keys are SHA-1’s and the values are pieces of content
Commit the changes into your local repository
git commit -m "Comment" git status (to check the status) git log (to check the logs)
What happens after a git checkout?
Git replaces files in the working area -> it changes to the content of the commit pointed at by the branch. Also: Moves the HEAD
How to see the content of a hash (low level plumbing command)?
git cat-file {SHA-1}
(you do not need to know the hash exactly, you may know just the beginning - git will open the correct object if there are not conflicts)
How do you force a push?
git push -f
(force push, as you can guess will overwrite the origin repository with your local versions of the project,
if used unwisely it might result in a loss of data)
What is a branch?
Branch in general understanding is just a reference to a commit. When working on a branch each commit will move the HEAD to the latest commit.
Before merging and pushing the project into origin, there might be need to get rid of all the conflicts.
What is the HEAD?
HEAD points us to the branch we are currently operating in. it is the (*), which is visible when you git branch. git checkout (allows us to switch between branches)
Three basic rules
- The current branch tracks new commits
- When you move to another commit, Git updates the working directory
- Unreachable objects are garbage collected
How to list references in a local repository?
git show-ref master (show state of remote and origing branches)
git show-ref –heads (will show the position of the head and the hash of the commit)