Git Flashcards
What is Git?
A distributed open-source version control system. You can work locally, then share or push your changes to a server (ex. GitHub or Gitlab)
main
the primary branch of all repositories.
branch
a version of the repository that diverges from the main working project. Branches can be a new version of a repo, experimental changes, or personal forks of a repository for users to alter and test changes.
fork
creates a copy of a repository.
merge
taking the changes from one branch and adding them into another.
“git clone LINK-HERE”
download an existing git repository to work on locally. git will download the entire repository (files and history). This only needs to be run once per repository since it creates a complete copy on your local machine.
Take the link from a remote repository (HTTPS). Then follow the flashcard “How to start a react repository?”
stage
you have marked a modified file in its current version to go into your next commit snapshot.
git add (command)
adds a change in the working directory to the staging area.
git commit -m “MESSAGE HERE” (command)
used to save your changes to the local repository. You normally want to group
git push (command)
updates a remote branch with local commits. the “-u” flag links the local branch with the remote branch, so the next time you can just use git push or pull without any arguments.
git status (command)
displays the state of the working directory and the staging area.
staging vs committing
The staging environment is where related modified files are added to a queue to be committed later. Committing captures a snapshot of the project’s currently staged changes. You want to stage related changes and then use commit to record those small changes. See the link for example: https://githowto.com/staging_and_committing
git pull
When you want to take changes or updates done by other developer/team member on git repository. “Git pull” fetches downloads the content from a remote repository and immediately updates the local repository/branch to match the content. In actuality, it is a combination of git fetch and git merge called in that order.
“git switch” (command)
switch between branches created by git branch. You can also use git checkout to switch branches.
“git log” (command)
View the history of committed changes within a git repository. To exit git log, type “q” or “z”. Type “h” to seek for help.