Git

What is Rebasing and why is Rebasing?

Submitted by Rajasekhar on Sat, 11/10/2018 - 13:32
  1. At a Glance - Sometimes we will want to incorporate new changes from the branch we branched from into our feature branch. To do this, we can use the Git rebase command.
    • Check out the feature branch to rebase.
    • Use the Git rebase command with the target branch.
    • Continue to work with new changes incorporated into the feature branch.
  2. What is Rebasing – A method of combining two branches that doesn’t create a merge commit.

How to resolve Merge Conflicts?

Submitted by Rajasekhar on Sat, 11/10/2018 - 13:28
  1. Sometimes, automatic merges will not be possible due to changes having been merged into the repository that our changes conflict with. To fix this, we need to follow the conflict resolution workflow.
    • Initiate the merge process using the Git merge command.
    • Manually choose which changes to merge into the master branch.
    • Commit the resolved merge changes to the repository.
  2. Conflicts arise if two branches edit the same part of the same file. Git can’t resolve the merge automatically.
Tags

How to use Tags in Git?

Submitted by Rajasekhar on Sat, 11/10/2018 - 13:19
  1. Sometimes we might want to designate a certain commit as one of significance, for example, a certain released version. We can do this using Git tags.
    • Add tags to certain commits with messages.
    • Push the tags to remote repositories.
    • Show the commit a tag points to.
  2. What are Tags? – Tags can be used to mark significant commits with a meaningful string value.

How to use Remote Repositories?

Submitted by Rajasekhar on Sat, 11/10/2018 - 13:16
  1. In order to share work with other programmers, we need to send to and pull changes from remote repositories. We can manage our repositories’ remotes using the Git remote command.
    • Use Git remote to show our configured remote repositories.
    • Add or remove remotes.
    • Fetch and merge changes into your local repository.
  2. Using Remote Repositories – Remote Repositories are copies of a repository hosted somewhere on the internet or your network. Allow you to collaborate with other developers.

How to Clone Repositories?

Submitted by Rajasekhar on Sat, 11/10/2018 - 13:12
  1. We won’t always start the projects we work on from our own machines. To begin working on an existing repository, we can clone the repository using Git clone.
    • Get the URL of the repository you want to clone.
    • Clone it to your local machine.
    • Start working on your clone of the repo.
  2. Cloning copies an existing git repository, usually from the internet. Copy repository in it’s entirely to your local machine. Keeps track of the repository’s remotes.

How to Undoing Mistakes?

Submitted by Rajasekhar on Sat, 11/10/2018 - 13:10
  1. Sometimes when programming, we introduce bugs that break the software we work on. Git can be used to easily revert the change that broke the program.
    • Identify the commit to be reverted
    • Use Git revert to undo the mistake
    • Commit the revert
  2. Sometimes, we need to correct errors in commits. Either by editing the message or by modifying its contents. We can also completely undo a commit or commits.
  3. git revert commit_ID (syntax).