Showing posts with label GIT. Show all posts
Showing posts with label GIT. Show all posts

Thursday, 15 June 2023

git pull error :error: remote ref is at but expected

Today I faced strange GIT error while running GIT pull command.

error: cannot lock ref 'refs/remotes/origin/Feature/Performance_Fix': is at 121133f24b3eda9c7167c7be2b0f31d282b0bbb2 but expected 58840e344e3d301761c726e4f833b83f6b261ecb

Solution : 

Run below commands to fix this issue (Update the object name stored in a ref safely, used this to delete the reference) 

git update-ref -d refs/remotes/origin/Feature/Performance_Fix

git pull


Thursday, 20 May 2021

Remove a file from git pull request

Learned something amazing today.

Scenario : You have updated a file that already existed in main branch and want to remove it from the pull request.

Assume you're working on a branch (say featureBranch) off of development (means you created 
featureBranch from the development  branch) , and your pull request includes a file named AccountController.java.

To remove this file from the pull request and revert its changes, simply do :

1. Checkout your branch (featureBranch).
2. Run below command.
     git checkout development --  AccountController.java
3. Commit and push into your branch (featureBranch).

Monday, 29 July 2019

Common git issues and their solution

While using git, I faced some small issues and found their solution online. Here is the consolidated list.

1. Refusing to merge unrelated histories.
Command : git pull
Error : fatal: refusing to merge unrelated histories
Solution : git pull --allow-unrelated-histories

2. There is no tracking information for the current branch.
Command : git pull
Error : There is no tracking information for the current branch. Please specify which branch you want to merge with.
Solution : git branch --set-upstream-to=origin/master master

3. Not a git repository.
Command : git remote add origin https://github.com/jagdevsingh87/ATG-REST-case-study.git
Error : fatal: not a git repository (or any of the parent directories): .git
Solution : git init

Wednesday, 15 May 2019

Resolved | GIT branch switch issue

While using GIT, encountered a special scenario. I was working on one branch. There were no changes local. Then I decided to switch to different branch.

I have faced below error.
===========================================================================
$ git checkout New_Temp_Branch
error : The following untracked working tree files would be overwritten by checkout:
      <list of files here>
Please move or remove them before you can switch branches.
Aborting
===========================================================================

Solution : Use below set of commands.

git add *
git stash
git pull

This will track all files, remove all of your local changes to those files, and then get the files from the server.