Git Issues and Resolution

1. How to revert Git repository to a previous commit?

As your commits are pushed remotely, you need to remove them. I assume your branch is develop and it is pushed over origin. You first need to remove develop from origin:
git push origin :develop (note the colon)

Then you need to get develop to the status you want, let me assume the commit hash is         COMMIT_HASH_123
git reset --hard COMMIT_HASH_123

Push develop again:
git push origin develop

2. How to merge two Git repositories?

To merge appA into appB:

cd path/to/appB
git remote add appA path/to/appA
git fetch appA
git merge --allow-unrelated-histories appA/master # or whichever branch you want to merge
git remote remove appA

--allow-unrelated-histories parameter exists since git >= 2.9

3. How to Edit git commit message in Git?

In Git Bash, navigate to your repository and enter:

git commit --amend

In text editor, edit the commit message and save it.
If code is not pushed to remote repo, then edited comment will appear when you push to remote

If code is already pushed to remote repo, use the command:
git push --force branch_name

Taken from : Github Help Page


Comments

Popular Posts

Elasticsearch, Logstash, Kibana Tutorial: Load MySQL Data into Elasticsearch

Dropwizard MySQL Integration Tutorial

Send Email in Java