Skip to content
Related Articles

Related Articles

Improve Article

What is Collaboration in Git?

  • Last Updated : 28 Jun, 2021

Collaboration is the way different people can work on the same project together. It is like creating a group in GitHub just like Groups in other social media. The people added to the collaborator’s list can be able to push, merge, and do other kinds of similar things on the project. 

For doing collaboration you need to follow the steps given below: 

Step 1: Create a Repository 
 

Step 2: Add files to your project. 
Open Git Bash into your local working directory where files are saved and follow the commands: 



$ git init
$ git add 
$ git commit -m "initial commit"
$ git remote add origin remote repository URL
$ git remote -v
$ git push -f origin master

Step 3: Adding your Collaborators. 
Click on setting and then follow below steps : 

After clicking on “Invite a collaborator” fill the required details and then you are done. 

Note: In order to perfectly work in a collaborative team you need to know below terminologies and their applications.

Creating signed and unsigned tags

First, the question arises why do we sign a code? 
Well, the reason is that it shows the authority of the code, that who has written it, and who needs to be blamed if any bug arises. To create a simple tag just write: 

$ git tag example

This creates a tag based on the current repository’s version. 
In order to create unsigned annotated tag containing a message just write : 

$ git tag -a v1 -m "Version 1 release"

At last if you want to sign on a tag just write : 

$ git tag -s mytag

In order to verify your signed tag just write :  

$ git tag -v mytag

git checkout

The git checkout command lets you navigate between the branches created by the git branch. It lets you check files in the working directory to match the version stored in that branch. 

$ git checkout branch_name 

This command can be easily confused with git clone but both are different. The difference between the two commands is that clone works to fetch code from a remote repository, alternatively, checkout works to switch between versions of code already on the local system.  

Other related Terminologies

  • push 
    This command is used to push the files from your local machine to the GitHub repository. 
$ git push -f origin master
  • fetch 
    It is useful when you are interacting with remote repository. Basically this command is used to retrieve the work done by other people and update your local project accordingly. 
$ git fetch remotename
  • pull request 
    It is a method of submitting your contributions to the project. It occurs when a developer asks for changes committed to an external repository to be considered for inclusion in a project’s main repository after the peer review. 
$ git pull remote_name
  • Fetch the specified remote’s copy of the current branch and immediately merge it into the local copy. This command is same as git fetch followed by git merge 
     
  • Deleting any tag 
    For deleting any tag navigate to your local GitHub repository and type the following command : 
$ git tag -d tagName 
$ git push origin :tagName 

Searching Code

GitHub provides users the feature to search code with a repository or organisation. Well there is some restrictions also imposed by GitHub while searching the code. This restrictions are imposed due to complexity of searching code. Below are the valid searches you can perform on GitHub.  

  • Search by the file contents or file path
  • Search within a user’s or organization’s repositories
  • Search by file location or file size
  • Search by language
  • Search by file name or file extension 
     

Check previous logs 
To look back into what are all the commits that are made in the repository you can simply use:  

$ git log

By default, if no argument is passed with this command. It will show the logs in reverse chronological order.
 

My Personal Notes arrow_drop_up
Recommended Articles
Page :