Git and GitHub Configuration Commands
1. Installation and Setup
Before you start, ensure that Git is installed on your system. If you haven't already, create a GitHub account to access the platform's features.
2. Initializing a Local Repository
To begin working on your project, navigate to your project folder. Right-click in the folder and select "Git Bash Here" to open the terminal.
3. Basic Git Commands
- Initialize a Local Repository:This command creates a new Git repository in your current directory.
- Check Status:This command displays the current branch, commit details, and any files that are not yet staged.
- Clone an Existing Repository:Use this command to copy an existing repository to your local machine.
- Stage Changes:
- To add a specific file:For example:
- To stage all files in the project:
- Commit Changes:This command commits the staged changes to your local repository.
This command creates a new Git repository in your current directory.
This command displays the current branch, commit details, and any files that are not yet staged.
Use this command to copy an existing repository to your local machine.
- To add a specific file:For example:
- To stage all files in the project:
This command commits the staged changes to your local repository.
4. Working with GitHub
- Login to GitHub: Access your GitHub account.
- Create a New Repository: Click on "Create Repository" and fill in the required details, including the repository name and visibility (select "Public" for free accounts).
- Connect Your Local Repository to GitHub:
- Copy the SSH URL of the newly created repository.
- Add the remote repository using:
- Push Local Changes to GitHub:This command uploads your local commits to the specified branch on GitHub. You may be prompted to enter your GitHub username and password.
- Copy the SSH URL of the newly created repository.
- Add the remote repository using:
This command uploads your local commits to the specified branch on GitHub. You may be prompted to enter your GitHub username and password.
Summary of Workflow With Command
- Push:
- Working Directory →
git add
→ Staging Area → git commit
→ Local Repository → git push
→ Remote Repository
- Pull:
- Remote Repository →
git pull
→ Local Repository → git checkout
→ Working Directory
By following this structured approach, you can effectively manage your projects using Git and GitHub, ensuring a seamless workflow from local development to remote collaboration. Whether you're a beginner or looking to refresh your skills, mastering these commands will enhance your coding experience.
- Working Directory →
git add
→ Staging Area →git commit
→ Local Repository →git push
→ Remote Repository
- Remote Repository →
git pull
→ Local Repository →git checkout
→ Working Directory
0 Comments