[Git]Merging Conflicted PRs

  1. Update the master
  2. Checkout a new branch from the master

git checkout -b new-branch master

3. pull the conflicting PR from the remote branch in remote repository

git pull https://github.com/denuwanthi/identity-inbound-auth-oauth.git remote-branch

4.Resolve merge conflicts

git add the modified files, and commit them

5.checkout the master

git checkout master

6.merge the new branch with resolved conflicts to master

git merge –no-ff new-branch

7.push the local master to your remote repository

git push origin master

 

Git applying patches

This quick blog post is about applying git patches to your git repo.

Command:

git apply [path to the patch file]

Ex:

git apply /home/denuwanthi/Downloads/product-greg.patch

Before applying the patch you can check wether there a re any issues using the following command.

git apply – -check [path to the patch file]

Ex:

git apply –check /home/denuwanthi/Downloads/product-greg.patch

If you don’t get any errors, you can apply the patch straight forward using the first command.

If you want to remove the change/patch you added, before committing, you can use

git checkout – – <file>

Ex:

git checkout — pom.xml

Removing unwanted files from showing in ‘git status’

Sometimes, when we do a ‘git status’ command, it displays unwanted files, asking us to track them. Ex:

git status

On branch master
Your branch is up-to-date with ‘origin/master’.

Untracked files:
  (use “git add <file>…” to include in what will be committed)

    atlassian-ide-plugin.xml

nothing added to commit but untracked files present (use “git add” to track)

In my case, it shows a plugin related file from my ide( atlassian-ide-plugin.xml). I don’t want this file to be shown in the git status command, but i need to have it in my working directory, in my hard drive.

Having such a line can be a distraction some times. So what can we do?

1. Go to your project root folder, and open the ‘.gitignore’ file at there.

2. Insert the unwanted file name there & save.

Ex: my .gitignore file

# Ignore everything in this directory
target
.classpath
.settings
.project
*.iml
*.iws
*.ipr
.idea
atlassian-ide-plugin.xml

3. Now do a ‘git status’ & see. That file & related message will not be shown again.

Sometimes, after that the console will show the following message.

git status

Changes not staged for commit:
  (use “git add <file>…” to update what will be committed)
  (use “git checkout — <file>…” to discard changes in working directory)

    modified:   .gitignore

Untracked files:
  (use “git add <file>…” to include in what will be committed)

    .gitignore~

no changes added to commit (use “git add” and/or “git commit -a”)

In this case, you can commit your updated ‘.gitignore’ file to your repository, so anyone using your repo will have the same file ignore configurations.

As for ‘.gitignore~‘ file , simply delete it manually.

 

Design a site like this with WordPress.com
Get started