Showing posts with label Git Stash. Show all posts
Showing posts with label Git Stash. Show all posts

Saturday, May 27, 2017

Git Merge Working Branch With Remove Branch

At first you nee to update your local branch using below command. It may better your have no local changes.

git pull

Then execute following command to update current branch with specific remote branch:

git merge remotes/origin/remote_branch

Sometimes it may prompt the following dialog:



Then you have to follow the below steps:

1. Press `i` to enable edit mode
2. Use down cursor go to the last line and introduce new line
3. Put some comments
4. Press `Esc` then `:wq!` and hit Enter key
5. You are done with merge
6. And finally execute "git push" to push changes

Sometime it may told you that some conflict occurred with the list of files, then you need to merge them before do merge.

After conflict occurred executed command "git merge --abort" to abort current merge request and then merge conflict before try again merge.

The simplest solution is fetch conflict file from the branch from where you want to merge using below command:

git checkout origin/branch_name app/directory/file.name

and push all files and then try again, i think it helps.

Sometimes it may need to stash your local changes before execute "git merge ..." command:

git stash

And after execute "git merge ..." execute below command to unstash changes:

git stash apply stash@{0}

To reset your current working branch:

git reset --hard (will move to previous commit)

And finally if you want to clear all untracked files execute:

git clean -fd