-
Notifications
You must be signed in to change notification settings - Fork 7
Home
Pankaj Chouhan edited this page May 31, 2024
·
1 revision
Welcome to the C-Programming-Tutorial-codeswithpankaj wiki!
Step-by-step tutorial to get you started with Git:
- Windows: Download and install Git from git-scm.com.
-
Mac: Install Git using Homebrew:
brew install git
. -
Linux: Use your package manager, for example:
sudo apt-get install git
.
Open your terminal and set your username and email:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
- Create a new directory for your project:
mkdir my_project cd my_project
- Initialize a Git repository:
git init
- Create a new file:
echo "Hello, Git!" > hello.txt
- Check the status of your repository:
git status
- Add the file to the staging area:
git add hello.txt
- Commit the file:
git commit -m "Add hello.txt with a greeting message"
- Go to GitHub and create a new repository (don't initialize it with a README).
- Connect your local repository to GitHub:
git remote add origin https://github.com/yourusername/your-repo-name.git
- Push your commits to the remote repository:
git push -u origin master
- Make changes to your file:
echo "Adding more content" >> hello.txt
- Check the status and see the changes:
git status
- Add and commit the changes:
git add hello.txt git commit -m "Update hello.txt with additional content"
- Push the changes to GitHub:
git push
- Create a new branch:
git branch new-feature
- Switch to the new branch:
git checkout new-feature
- Make changes and commit them in the new branch:
echo "This is a new feature" > feature.txt git add feature.txt git commit -m "Add new feature"
- Push the new branch to GitHub:
git push -u origin new-feature
- Switch back to the master branch:
git checkout master
- Merge the new branch into the master branch:
git merge new-feature
- Push the changes to GitHub:
git push
- Clone a repository from GitHub:
git clone https://github.com/username/repo-name.git
This is a basic overview to get you started with Git. As you become more comfortable, you'll learn more advanced features and workflows.