This guide includes essential Git and GitHub commands that are commonly used in version control and collaborative development.
Download and install Git. During installation, accept the default settings unless you have specific preferences.
Open your terminal or command prompt and configure your user information for Git using the following commands:
git config --global user.name "Your Name"
git config --global user.email "your-email@example.com"Navigate to the directory where your project is located and initialize it as a Git repository (if not already done):
git initAdd your project files to the repository. You can add individual files using:
git add filenameOr add all files in the directory with:
git add .Commit your added files to your local repository:
git commit -m "Initial commit"Replace "Initial commit" with a meaningful message describing what you are committing.
(i) Go to GitHub and sign in.
(ii) Click the "+" icon in the top right corner and select "New repository."
(iii) Name your repository, add a description (optional), and choose whether it's public or private.
(iv) Click "Create repository."
Copy the URL of your newly created GitHub repository. Then, link your local repository to GitHub with:
git remote add origin <REPOSITORY_URL>Replace <REPOSITORY_URL> with the URL of your GitHub repository.
Finally, push your code to GitHub with:
git push -u origin mainFor any subsequent pushes after the initial push, you can simply use:
git pushThese steps cover the basics of pushing code from a local repository to a GitHub repository.