Introduction
Git is widely use by the developer for working on a single project by multiple users from multiple devices. Uses can share their code and get another developer code by the git without sharing the files and folder.
Install git for windows
Step 1: download git from here and install it on your PC
Step2: click on next to all default setting and it will install finally in c drive by default
Set up an account on github.com
Step 1: login and signup on the github.com
Step 2: Create a repository for your project
Step 3: Create a branch for your self and one more for another developer who will also work on the same project
Step 4: to give the repository access to another developer you can invite him for the same repository.
Setup get repository on your local machine
step 1: open command prompt
Step 2: switch to the folder where you want to store the repository
Step 3: copy the repository URL from the GitHub
Step4: now write the command in the command prompt with your repository URL
git clone --single-branch --branch branch1 https://github.com/DeepakSharma78400/testing_repo.git
Step5: Open the folder in your favorite code editor here I will use VS Code.
If the terminal asked for the user name and password to take cole then run the below commands in CMD
git config --global user.email johndoe@example.com git config --global user.password ●●●●●●●●●●●
Step6: create a new file and some line in the file and save
Step7: write the below command sequentially whenever you push the code in a repository
Git add . Git status
Note: – this command show you which file has changed as compare to the previous version of the project
Git commit -m “message”
Note: – this command used to commit the code with a message for which purpose this code has been a return
Git pull origin main
Note: – here you will write your main branch name where all branches code will merge
Git push -u origin branch1
Note: – replace your branch name from the branch1
How to raise the Pull Request
Step1: Login to your GitHub account on the github.com
step2: go to your repository and click on the pull request tab. On the pull request page, you will see a button new pull request click on that button
Step3: select the correct branch from which branch to which branch you want to merge the code
Step 4: then click on create a pull request
Step 5: then merge the pull request
Now run the below command in another branch on which another developer working and he wants your code in his code
Git pull origin main
Thank you Hope this blog is valuable for you.