Kannan Sudhakaran

Kannan Sudhakaran

14 Articles Published

Articles by Kannan Sudhakaran

14 articles

How to add collaborators to a repository in GitHub?

Kannan Sudhakaran
Kannan Sudhakaran
Updated on 30-Apr-2021 5K+ Views

Even if you have a public repository in GitHub, not everyone has the permission to push code into your repository. Other users have a read-only access and cannot modify the repository. In order to allow other individuals to make changes to your repository, you need to invite them to collaborate to the project.The following steps should be performed to invite other team members to collaborate with your repository.Step 1 − Click on the Settings tab in the right corner of the GitHub page.Step 2 − Go to Manage Access option under the Settings tab. On the Manage Access page, you ...

Read More

How to create a GitHub repository

Kannan Sudhakaran
Kannan Sudhakaran
Updated on 30-Apr-2021 2K+ Views

A GitHub account is a pre-requisite for creating a GitHub repository. Follow the below steps after registering with GitHub.Step 1 − Login to the GitHub account. Once you login to your account you will see a ‘+’ button on the right. Click on the button and select "New repository" option to create a new repository.Configure the following in the create a new repository page.Repository name: GitHub will validate the repository name that you have entered.Type of the repository: GitHub lets you create the following types of repositories −Private repository − Private Repository is the one that can be accessed only ...

Read More

How to clone a GitHub repository?

Kannan Sudhakaran
Kannan Sudhakaran
Updated on 30-Apr-2021 2K+ Views

Cloning a repository involves downloading a copy of the source code from source control. In other words, cloning is creating a copy of an existing repository. Consider an example where multiple users are working on a project. This feature can be used by the users to create a development copy.If you have a GitHub repository, you need to first invite collaborators into the repository. Each collaborator will then clone the repository into their local machines.Locally they will work with this cloned repository, make local changes and perform commits on it. Once they are ready to share their changes with others ...

Read More

Explain rebasing in Git

Kannan Sudhakaran
Kannan Sudhakaran
Updated on 30-Apr-2021 1K+ Views

Rebasing alters a sequence of commits. It moves or relocates a sequence of commits from current branch to the target branch. By default, the commits from the current branch that are not already on the other branch are rebased. Rebasing technique allows us to keep a linear history.Let us understand from this from the diagram below.To rebase we need to be in the branch which needs to be rebased into the target. In our scenario, we need to execute the rebase command on the feature branch. After executing the rebase command we will get a linear history.After executing the rebase ...

Read More

How to undo a faulty merge with reset command in Git?

Kannan Sudhakaran
Kannan Sudhakaran
Updated on 30-Apr-2021 2K+ Views

Let us say we performed a merge commit and later found out that the code is not compiling or our application is not working. This happens if we make mistakes while merging. In situations like these we need to undo the merge using either −reset command; ORrevert commandThe git reset command can be used to undo local changes to the state of a Git repository. A git reset moves the HEAD pointer to a given commit and updates the index to match that commit. This command rewrites the commit history. However, if we have shared our commits with other team ...

Read More

Explain soft reset with an example in Git

Kannan Sudhakaran
Kannan Sudhakaran
Updated on 30-Apr-2021 889 Views

Soft reset will move the HEAD pointer to the commit specified. This will not reset the staging area or the working directory.ExampleThe diagram shows a file named File1.txt within the git repository. A, B, C and D represent lines that are added to the file. The diagram indicates that a commit is performed after adding each line A, B and C. c1 is the commit performed after adding line A, c2 is the commit after adding line B and C3 represents the commit after adding line C.Now add line D. This change is available in the working directory and this ...

Read More

Explain how reset command works in Git

Kannan Sudhakaran
Kannan Sudhakaran
Updated on 30-Apr-2021 987 Views

The commit command moves the HEAD of a branch implicitly. The below diagram shows that initially HEAD was pointing to commit c1. After each commit operation the HEAD pointer moves ahead to the new commit. We can perform a reset using the HEAD pointer or commit hash.The git reset command will explicitly or forcibly move the HEAD of the branch to a specific commit.When resetting the HEAD pointer, we have 3 options −SoftMixedHardHard ResetWhen performing a hard reset, git will copy the commit snapshot into the working area as well as the staging area. Due to this any changes done ...

Read More

How to abort a merge conflict in Git?

Kannan Sudhakaran
Kannan Sudhakaran
Updated on 30-Apr-2021 2K+ Views

When doing a merge, you may run into one or more conflicts. Now what if we are not quite ready to handle this conflict yet. Perhaps you have several conflicts and you don't have enough time to spend on resolving these conflicts. In situations like this we can easily go back to the state before we started the merge.To abort the merge, we can use the following command$ git merge --abortNote that if we execute this command after resolving some conflicts and staging the changes, then these changes would not be saved. Once the command is fired, we are back ...

Read More

How to view merged and unmerged branches in Git?

Kannan Sudhakaran
Kannan Sudhakaran
Updated on 30-Apr-2021 7K+ Views

When we have multiple branches in a git repository, we would need to bring the changes from all the branches to the main line of work that is the master branch. So, if we are currently in master branch and need to see which branches need to be merged, we can use the following commands.$git branch --no-mergedWe would also need to verify which branches are already merged, so that we can delete the unused branches$git branch --mergedExampleLet us create an example to understand how to view the branches that are merged and unmerged. The following diagram shows that there are ...

Read More

How to disable fast forward merges? What are its pros and cons in Git?

Kannan Sudhakaran
Kannan Sudhakaran
Updated on 30-Apr-2021 2K+ Views

Fast forward merges can be disabled −At the time of mergingFor the entire repositoryFor all repositories.Disabling fast forward merges has both pros and cons.When we disable fast forward merge, git will perform a merge commit to merge the changes from both the branches. The drawback of merge commit is that it becomes hard to read and understand the commit history, especially when we have many branches. If your team prefers to keep a linear history of branches, then one should go for fast forward merge. Disabling fast forward merge will create merge commits, which pollutes the commit history.The benefits of ...

Read More
Showing 1–10 of 14 articles
« Prev 1 2 Next »
Advertisements