Latest Update related to Science and Technology

###

How to PUSH,PULL,MERGE in Github?

Github Working

GitHub is a remote platform for resource sharing. Resources includes the Software Project, Documentation, Programming Code and many more. GitHub act as a remote server and user PC is the local server. GitHub turns out to be helpful for programmers and engineers since we whole project can be stored in cloud. User can access, update, retrieve, authorize the repository( a folder which stores our project). Since it is a remote platform anyone can access GitHub repository from anywhere in presence of internet connection.

Steps to be followed for proper PUSH operation

1)After creating a repository in GitHub create a folder for your project in any location of your PC.

2)Open the command prompt and navigate to your project folder.

3)Write command  git init and press enter which initialized the repository.

4)Write command git branch -M main here this command creates a new branch main since by default only master branch is present in github.

5)Write command git checkout main this command switches from default master branch to main branch

6)Write command git add yourfilename here your filename means the file’s name you want to add to Github. The file should be present within the project folder.

7)Write command git commit -m "Your comment to the addition made" In the ” ” you have to add notation such as eg. change made in filenameone.js

8)Write command git remote add origin https://github.com/username/repository-name.git here the link written can be found after clicking code tab in your github project repository as

Your github link

After pressing enter with this command remote origin added messege is shown in cmd window.

9)Write command git push -u origin main Your file is now successfully pushed into github repository.

IN case you and your friend are working in different code and pushing in different branch but in same repository.  Create a single common repository in any of github account in case you create repo your friend has to fork else you have to fork.Then follow the commands below:

1)Search for your friends GitHub account and chose the repository wanted.                                                            Click on the “Fork” button located at the top right corner of the repository page. This will create a copy of the repository under your GitHub account. Wait for the forking process to complete. Once finished, you will be redirected to the forked repository under your account.

3)You can find your friend repository mentioned inside your account after the fork completed. Enter inside that repository.

4)Then inside that repository create a master or main branch looking upon which your friend has created for this portion. If your portion is master branch then follow the same code above mentioned and remove step 4),5). In case of adding remote origin put the link as done above from the repo you are currently in and finally add this command git push master. One file addition with some data is compulsory in order to merge and pull.

5)Now your friend also needs this update done in his account since doing this in from your account doesn’t update in his account. Ask your friend to create a master branch from his PC following the above steps and add certain file. Now you are going to merge and pull the master from  your repo to friend’s repo.

Your friend should navigate to the repository on GitHub in a web browser.

Click on the “Settings” tab, usually located near the top of the repository page.

In the left sidebar, click on “Manage access” or “Collaborators & teams”, depending on the GitHub interface.

In the “Collaborators” section, your friend can search for your GitHub username and add you as a collaborator.

Once your friend finds your username, they can click on it to grant you access to the repository.

Depending on the repository settings, your friend may need to confirm the addition or send an invitation to collaborate. You might receive an email or notification prompting you to accept the invitation.

Once you have been added as a collaborator, you should have the necessary permissions to create pull requests in your friend’s repository.

6)Now you have to hover to pull request mentioned in navigation bar of GitHub repo. Then you can find create pull request or compare pull request. You have to create pull request with your master branch selected and friends master branch selected. Then your friend can accept the pull request and then his repository which originally in forked will also be updated with code.

Working of GitHub

WorkFlow of Github

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Articles