Installation and Basic Commands for Windows and Linux
GitHub, Getting Started
GitHub is a web-based platform for version control and collaboration that allows developers to store, manage, and collaborate on their projects. GitHub uses Git, a distributed version control system created by Linus Torvalds, the creator of Linux.
What is GitHub?
GitHub is a Git repository hosting service that provides a simple, user-friendly interface for managing and collaborating on projects. It offers a wide range of features, including:
- Version control: Keep track of changes to your code and revert to earlier versions if necessary.
- Collaboration: Invite team members to contribute to your project and review changes before merging.
- Issue tracking: Track and manage bugs, enhancements, and other project-related issues.
- Project management: Use tools like boards and milestones to organize and prioritize your work.
- Integration: Connect with third-party tools and services like continuous integration and deployment systems.
Installing GitHub on Windows
- Download the Git for Windows installer from the official website: https://git-scm.com/download/win
- Run the installer and follow the setup wizard.
- Choose the components you want to install (default options are usually sufficient).
- Select the text editor you want to use with Git (e.g., Notepad++ or Vim).
- Configure the PATH environment variable to include Git (choose “Use Git from theWindows Command Prompt” or “Use Git and optional Unix tools from the Windows Command Prompt”).
- Choose the HTTPS transport backend (the default option is recommended).
- Configure line-ending conversions for your working directory (choose “Checkout Windows-style, commit Unix-style line endings” for cross-platform compatibility).
- Configure the terminal emulator to use with Git Bash (the default option is recommended).
- Click “Install” to complete the installation process.
Once installed, you can access Git by right-clicking on a folder in Windows Explorer and selecting “Git Bash Here” or by opening the Git Bash application from the Start menu.
Installing GitHub on Windows
- Download the Git for Windows installer from the official website: https://git-scm.com/download/win
- Run the installer and follow the setup wizard.
- Choose the components you want to install (default options are usually sufficient).
- Select the text editor you want to use with Git (e.g., Notepad++ or Vim).
- Configure the PATH environment variable to include Git (choose “Use Git from the Windows Command Prompt” or “Use Git and optional Unix tools from the Windows Command Prompt”).
- Choose the HTTPS transport backend (the default option is recommended).
- Configure line-ending conversions for your working directory (choose “Checkout Windows-style, commit Unix-style line endings” for cross-platform compatibility).
- Configure the terminal emulator to use with Git Bash (the default option is recommended).
- Click “Install” to complete the installation process.
Once installed, you can access Git by right-clicking on a folder in Windows Explorer and selecting “Git Bash Here” or by opening the Git Bash application from the Start menu.
Installing GitHub on Linux
- Open the terminal (Ctrl+Alt+T).
- Update the package list using the following command:
sudo apt-get update
- Install Git using the following command:
sudo apt-get install git
- Verify the installation by checking the Git version:
git --version
- Configure your Git user name and email using the following commands (replace “Your Name” and “you@example.com” with your actual information):
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
Basic Commands to Know for Using GitHub
git init
: Initializes a new Git repository in the current directory.git clone <repository_url>
: Creates a copy of a remote repository on your local machine.git add <file>
: Adds a file to the staging area, preparing it for a commit.git commit -m "<message>"
: Commits the changes in the staging area with a descriptive message.git status
: Shows the status of your working directory, including modified files, staged changes, and untracked files.git log
: Displays the commit history in your repository.git diff
: Shows the differences between the working directory and the last commit.git remote add origin <repository_url>
: Connects your local repository to a remote GitHub repository.git push -u origin <branch_name>
: Pushes your changes to the remote repository on the specified branch (usually ‘master’ or ‘main’).git pull
: Fetches changes from the remote repository and merges them with your local branch.git fetch
: Fetches changes from the remote repository but does not merge them.git merge <branch_name>
: Merges changes from the specified branch into your current branch.git branch
: Lists all branches in your repository and shows the current active branch.git checkout <branch_name>
: Switches to the specified branch.git checkout -b <new_branch_name>
: Creates a new branch and switches to it.git branch -d <branch_name>
: Deletes the specified branch.
Conclusion
Now that you have been shown how to install GitHub on Windows and Linux and are familiar with some basic commands, you’re ready to start using GitHub to manage and collaborate on your projects. Remember, practice is key when it comes to mastering Git and GitHub.