git Flashcards
(11 cards)
git add
Purpose: Adds changes in the working directory (modified or new files) to the staging area in preparation for committing.
When to Use: After editing or creating files, and before committing those changes to the repository.
git commit
Purpose: Records changes from the staging area into the repository’s history. A commit represents a snapshot of your project.
When to Use: After using git add to stage changes, and when you’re ready to save your progress with a meaningful message.
git push
Purpose: Sends your local commits to a remote repository (e.g., on GitHub).
When to Use: After committing changes locally and when you want to share your work with others or back it up to the remote repository.
git pull
Purpose: Fetches the latest changes from a remote repository and integrates them into your current branch.
When to Use: When you want to update your local repository with changes made by others or on the remote server.
git clone
Purpose: Creates a local copy of a remote repository.
When to Use: When you want to start working on an existing project hosted on a remote platform (e.g., GitHub).
Fork
Purpose: Creates a personal copy of someone else’s repository on your GitHub account.
When to Use: When you want to contribute to another repository or experiment with it without affecting the original repository.
Branch-and-Merge Workflow
Purpose: A strategy for collaborative development where changes are made in separate branches and later merged into the main branch.
When to Use:
When developing new features or fixing bugs, so you can isolate your work from the main codebase.
Pull Request
Purpose: Proposes changes from one branch (typically on a fork or feature branch) to be reviewed and potentially merged into another branch (e.g., the main branch of the original repository).
When to Use: When you want others to review your changes before they are merged into the project’s main codebase.
Reasons for Using Version Control (Git)
Collaboration: Enables multiple developers to work on the same project without conflicts.
Change Tracking: Tracks every change to the codebase, including who made changes and why.
Branching and Merging: Allows developers to experiment in isolated branches and merge changes safely.
Backup and Recovery: Provides a history of changes, enabling easy rollback to previous versions if needed.
Code Quality: Supports code reviews and collaboration workflows like pull requests.
Distributed Development: Facilitates working across different locations with a distributed repository model.
Continuous Integration: Integrates easily with CI/CD pipelines to automate testing and deployment.
What is a non-trivial merge conflict between two branches?
A non-trivial merge conflict occurs when Git cannot automatically reconcile changes between two branches during a merge because the changes are too complex or involve overlapping modifications.
common ways that merge conflicts are resolved
Local merge/rebase to the feature branch and push.
Local merge/rebase the main branch and push.
Merge request (i.e. GitHub pull request)