This repository contains two key resources to help you get started: a PDF presentation with all the essential information about Google Summer of Code (GSoC), including guidance on applying, selecting projects, and succeeding in the program, and a comprehensive Git guide that covers the setup process, key commands, and GitHub terminology.
This guide will help you set up Git for the first time and walk you through the most commonly used Git commands with explanations and examples.
-
Download Git:
- Visit git-scm.com and download Git for your operating system.
-
Install Git:
- Follow the installation wizard and configure options (use defaults if unsure).
-
Verify Installation:
git --version
- This command displays the installed Git version.
Before using Git, set your username and email address (these are attached to your commits):
-
Set your username:
git config --global user.name "Your Name"
-
Set your email:
git config --global user.email "[email protected]"
-
Check your configuration:
git config --list
- This shows all your Git configuration settings.
- Navigate to your project folder:
cd /path/to/your/project
- Initialize Git in the folder:
git init
- This creates a
.git
directory to track your project's version history.
- This creates a
Why: Stage changes before committing them.
git add <file> # Stage a specific file
git add . # Stage all changes in the current directory
Why: Save a snapshot of your staged changes.
git commit -m "Your commit message"
Why: See which files are staged, modified, or untracked.
git status
Why: See a list of previous commits.
git log
Why: Link your local repository to a remote one (e.g., on GitHub).
git remote add origin <repository-url>
Why: Upload commits to the remote repository.
git push origin <branch-name> # First push
git push # Subsequent pushes
Why: Sync your local repository with the latest changes from the remote.
git pull
Why: Work on features independently without affecting the main branch.
git branch <branch-name> # Create a branch
git checkout <branch-name> # Switch to the branch
Why: Combine changes from one branch into another.
git checkout main
git merge <branch-name>
Why: Revert uncommitted changes.
git checkout -- <file> # Discard changes in a file
git reset HEAD <file> # Unstage a file
Why: Create a local copy of a remote repository.
git clone https://github.com/user/repository.git
A repository is a storage space for your project, including all files and version history.
A commit is a snapshot of changes made to a repository. Each commit has a unique ID and an associated message.
git commit -m "Added feature"
A Pull Request (PR) is a request to merge changes from one branch into another. It allows others to review and discuss the proposed changes before integrating them.
A fork is a personal copy of someone else's repository. It allows you to experiment with changes without affecting the original repository.
Staging means preparing files for a commit. You add files to the staging area using git add.
A branch represents an independent line of development. Branches allow you to work on different features or fixes without affecting the main codebase.
git checkout -b new-feature
Merging integrates changes from one branch into another. This is commonly done via Pull Requests.
Checkout switches to a different branch or commit.
git checkout new-feature
Command | Purpose | Example |
---|---|---|
git init |
Initialize a Git repository | git init |
git add . |
Stage all changes | git add . |
git commit -m "" |
Save changes with a message | git commit -m "Added new feature" |
git status |
Check repo status | git status |
git log |
View commit history | git log |
git remote add |
Link to remote repository | git remote add origin <repo-url> |
git push |
Upload changes to remote repo | git push -u origin main |
git pull |
Download changes from remote repo | git pull |
git branch |
Create or view branches | git branch <branch-name> |
git checkout |
Switch to a branch | git checkout <branch-name> |
git merge |
Merge another branch into the current branch | git merge <branch-name> |
- Track Changes: See how your code evolves over time.
- Collaboration: Work with others without overwriting their changes.
- Backup: Keep your code safe on remote repositories like GitHub.
- Version Control: Revert to earlier versions when needed.
This setup and command list will help you get started with Git confidently!