A repository used for our "Good First Bug" Sessions where we walk the participants through the process of contributions on a Git Version control environment.
The objective of this exercise is to introduce beginners to basic Git and GitHub commands. By completing this exercise, participants will gain hands-on experience with version control and collaboration using Git and GitHub.
If we decide to initialize a new repository, we need to use the git init command. It turns the current directory into a Git repository and starts tracking its content:
$ mkdir simple-repo; cd simple-repo; git init
Initialized empty Git repository in /simple-repo/.git/Git also creates a hidden directory called .git in it. This directory stores all the objects and refs that Git creates and uses as part of our project’s history.
After that, in most cases, we want to connect our already created repository with a remote one. We use the git remote command to manage remote links for the current repository:
$ git remote add origin https://github.com/mukticommunity/tutorials.gitWe’ve just added a new remote called origin and connected it to the official MUKTI GitHub repository.
Our local repository consists of three different trees maintained by Git.
The first one is the Working Directory, which holds the actual version of files.
After making our changes to the files, we can move the files into Index, which acts as a staging area. We do this using the git add command. Files in Index begin to be tracked by Git.
Finally, we can apply and save our changes into the **Local Repository **using the git commit command. Committing the changes updates the repository’s HEAD, which always points to the last commit we’ve made.
Those three steps are used to maintain the local changes. But as we know, the repository may also contain an external source. The last step is to synchronize both repositories and publish our changes.
Refference: Baeldung
- If you don't have a GitHub account, create one.
- Log in to your GitHub account.
- Go to the exercise repository: Galti-Se-Mistake.
- Click on the "Fork" button in the top right corner to create a copy of the repository in your GitHub account.
-
On your forked repository, click on the "Code" button and copy the repository URL.
-
Open your terminal (or Git Bash on Windows).
-
Navigate to the directory where you want to clone the repository.
-
Run the following command:
git clone <repository-url>
Replace
<repository-url>with the URL you copied.
-
Navigate into the cloned repository:
cd Galti-Se-Mistake -
Open the
contributors.mdfile using a text editor or run:touch CONTRIBUTORS.md
-
Add your name to the file, following the example:
- [Name](Link to your GitHub Profile)-
Add your changes to the staging area:
git add . -
Commit your changes:
git commit -m "Add your name to CONTRIBUTORS.md"
-
Push your changes to your GitHub repository:
git push origin main
Note: If you are on a branch other than
main, replace it with the name of your branch.
- On your GitHub repository, click on the "Pull Requests" tab.
- Click the "New Pull Request" button.
- Compare changes and click "Create Pull Request."
- After creating the pull request, click on the "Merge Pull Request" button.
- Confirm the merge.
Congratulations! You've successfully completed the Git and GitHub exercise by adding your name to the CONTRIBUTORS.md file. This exercise covers basic concepts like forking, cloning, making changes, committing, pushing, and creating a pull request.
