Git
Branching and Merging
- Branching allows you to work on new features or fixes without affecting the main code.
git branch <branch-name>
– creates a new branch.git checkout <branch-name>
– switches to the branch.git switch <branch-name>
– alternative to checkout (recommended in newer versions).git merge <branch-name>
– merges the specified branch into the current branch.- Helps in parallel development, testing, and safer collaboration.
Remote Operations
- Remote repositories are versions of your project hosted online (e.g., GitHub, GitLab).
git remote add origin <URL>
– links your local repo to a remote.git push
– uploads your commits from local to remote.git pull
– fetches and merges changes from the remote to your local branch.git fetch
– only downloads changes (doesn’t merge).- Keeps your local and remote repositories in sync for collaboration.
GitHub / GitLab Basics
- GitHub and GitLab are platforms to host Git repositories online.
-
Features:
- Remote storage and version control
- Collaboration via Pull Requests / Merge Requests
- Issue tracking, discussions, project boards
- Private or public repositories
- GitHub Pages (for static website hosting)
- GitHub is widely used; GitLab is popular for built-in CI/CD and DevOps tools.