Skip to main content

Questions tagged [git-reset]

Sets the current Git repo head to a specified commit and optionally resets the index and working tree to match.

git-reset
Filter by
Sorted by
Tagged with
0 votes
2 answers
39 views

Regarding the repercussions of git hard reset on remote

Resetting remote to a certain commit We would like to reset the remote to a certain commit on a specific branch (say branch A) in our project. However there are the following concerns: We recently ...
Vinod's user avatar
  • 1,053
-1 votes
1 answer
61 views

Is there a way to reset or remove all my commits into the dev branch?

I have been working on different branches and anytime task is ready I commit and create a pull request into the dev branch. Till now everything is okej, but is there a way to reverse or remove all ...
Anxheloo's user avatar
-1 votes
2 answers
45 views

how to push an old reseted or reverted heads

I can go back and forward in my history using git checkout heads git revert heads git reset heads And when I do git push origin main I get Everything up-to-date and no change on remote server. how to ...
Besmella Kazimy's user avatar
2 votes
1 answer
73 views

How to reset committed file permission changes (mode change)?

I changed the permissions of all my files and directories of my git repository and committed it to my main branch, eg. mode change 100755 => 100644 path/to/file.sh I wanted to reset now these ...
Coding Monkey's user avatar
0 votes
3 answers
82 views

Need to recover from multiple errant `git reset` commands

I know that undoing a single git reset or git reset --hard command has been asked and answered, but I have really messed things up and am not sure how to proceed because I need to undo several ...
bmitc's user avatar
  • 735
-1 votes
3 answers
50 views

How to remove a feature from master-dev after has been intermingled with other feature commits?

Let's say we have a git repo with a master-dev branch. When developers complete their features, each feature branch in merged into the master-dev. One day, A large feature is merged into master-dev ...
Hoyt Jolly's user avatar
-2 votes
1 answer
107 views

Reset all files affected by past commit to the state before that commit

How do I reset all (and only) files affected by a given commit to the state before that commit? I only need to reset the files in the commit, not the entire repository or single file/directory, and I ...
Anton Duzenko's user avatar
0 votes
0 answers
63 views

Can't use reset --hard on individual file?

I had a patch I wanted to apply on a fresh branch, and commit. (I was trying to rescue myself from the problem described at this question.) So I did git apply patchfile git add file1 git add file2 git ...
Steve Summit's user avatar
  • 46.9k
-1 votes
1 answer
53 views

I want to bring back COMMITED but then deleted files on my local repository after doing git reset hard

I have staged and commited a very large folder (created and only present on my local repository) but then I did git reset hard to revert my big commit which was a mistake. However, luckily, I commited ...
Luc's user avatar
  • 1
0 votes
0 answers
59 views

How do I cancel a merge commit (non-squash)?

In this case, if you output git log --online, you should see something like this c6 merge iss53 to master c5 c3 c4 c2 c1 ... As you can see, c4,c6 are commits from the master branch, and c5,c3 are ...
JoonT's user avatar
  • 1,206
0 votes
1 answer
71 views

I accidentally git reset --hard in the first initial commit, how to restore it back?

I noticed error with the initial commit. So I ran 'git reset --hard origin/master' command. After this command it deleted all the files locally and didn't see anything, How can I restore all files
Mixko's user avatar
  • 603
1 vote
3 answers
108 views

Wrong git commit to trunk in local, how to pull clean from remote?

After doing some changes I committed them locally to the trunk before branching. I then branched and pushed my changes to the remote repository. Now the remote repository has the changes it needs to ...
André's user avatar
  • 1,906
2 votes
5 answers
2k views

How do I check what `origin` references in my remote repository?

For as long as I used git, if I want to reset my local branch to the remote master branch, I've done git reset --hard origin and this seems to work empirically, but I recently learned that this might ...
roulette01's user avatar
  • 2,346
1 vote
2 answers
4k views

git "You have divergent branches" when I havent made any changes or commits

I cloned a repo, then later I want to pull the latest version. I have made no modifications or commits locally. However, git pull says this: fatal: Need to specify how to reconcile divergent branches. ...
John Little's user avatar
  • 11.7k
-2 votes
2 answers
311 views

How can I reset to the main branch in git

I want to make my current branch exactly the same as my main branch. When I do 'git reset --hard main', it does the job. But then when I push it complains that it is behind. error: failed to push some ...
Charles's user avatar
  • 357
-1 votes
2 answers
434 views

Unknown revision or path not in the working tree on git reset --soft

I want to squash all the commits till a particular commit-id in a branch. I tried using the command git reset --soft HEAD~223 The number 223 was generated as follows: I ran the command git rev-list ...
pensee's user avatar
  • 465
0 votes
0 answers
26 views

Where is the git documentation that specifies that a reset can take a branch name as an argument?

I've scanned the documentation here and I see no mention of how to reset to a branch's latest commit. I only see [<commit>] used but sure enough, you can specifiy 'origin/develop' in git reset --...
IEnjoyEatingVegetables's user avatar
0 votes
1 answer
434 views

git reset --hard HEAD~1 [duplicate]

Is there any chance of recovering files that were not committed before this command? I used this command instead of --soft.... I am working on Linux/Visual Studio code 035e859 HEAD@{23}: reset: moving ...
Corristo's user avatar
0 votes
1 answer
73 views

Change files in working directory while not changing branch

In order to create a clean commit history and get rid of some files I don't want for a PR, I would like to set my working directory to be at the state of my branch, say B, but make git remain on ...
Cornelius Roemer's user avatar
-1 votes
1 answer
282 views

What is the difference between "git reset --hard HEAD~1" and "git checkout ."?

I'm currently learning git, and I have issue what exactly do these commands do? git reset --hard HEAD~1 git checkout . What's the difference between the two? They both permanently delete the last ...
Juan Fruto's user avatar
0 votes
0 answers
27 views

How do I hard reset a branch to a previous state when the tip of the branch is behind [duplicate]

I merged two branches into develop on 1st June which broke the working copy of develop branch. I am trying to hard reset these two branches to the last stable branch which is from 26th January. I did ...
Nadera Sultana Tany's user avatar
0 votes
0 answers
2k views

How to apply `git reset HEAD~1` on the Github instead of the local repository?

By mistake I committed changed to my main branch and pushed the changes to the server/Github. I want to completely get rid of the commit on GitHub. The command git reset HEAD~1 undo the last commit ...
Jay's user avatar
  • 1,910
0 votes
1 answer
197 views

How can I undo that unstaged changes were deleted by git reset --hard HEAD^? [duplicate]

I was working on my project, and I made a wrong commit (the last commit) and wanted to permanently delete it from the git logs, and I did the following command: git reset --hard HEAD^ The problem is ...
user11555842's user avatar
0 votes
1 answer
176 views

Lost all the files using git reset --hard and while recovering I get my lost files in hash file format which makes me difficult to recover them

I used git reset --hard command and lost all my files. Then tried to use command git fsck which got me a dangling tree with a hash value. Then entered the git show --format=raw <hash value> ...
Ankush_anonymous's user avatar
0 votes
4 answers
926 views

Git: I can't seem to reset my local main to origin/main

I want to do something very simple: update my local main to the remote one. Except it seems HEAD and origin/main are somehow pointing to an old commit. I want to fast forward HEAD and can only seem to ...
Amnon Attali's user avatar
2 votes
2 answers
88 views

Git - changing the branch tip to include commits from another branch

I have a git workflow scenario question and have provided the "current" and "desired" branch structures, but I don't know the correct commands to get to the desired state. Current: ...
Vada Poché's user avatar
0 votes
1 answer
57 views

Git - Reset commit in master or cherry-pick / merge to sync up master's commit to other branch

Initially I have master and develop branch at the same state, but I accidently make some commits directly to the master. Now I'm going to sync the master's commit to develop, but our practices is ...
Tony_Ynot's user avatar
  • 155
0 votes
1 answer
107 views

git reset HEAD~1 vs git branch -f mainline HEAD~1

Assuming, current branch is mainline. mainline and HEAD pointer are pointing to the latest commit. git reset HEAD~1 git branch -f mainline HEAD~1 To the best of my understanding both the commands ...
Prakarsh Pathak's user avatar
1 vote
1 answer
206 views

How to restore deleted commits on pythonanywhere

I have accidentally deleted my commits on pythonanywhere.com and now I see very old state of my files. My Django website isn't working at all. What I did: $ git reset --hard HEAD~1 And then: $ git ...
Percival's user avatar
0 votes
1 answer
48 views

Difference between "git reset HEAD <filename>" and "git reset -- <filename>"?

When I stage a file, "git status" then mentions that, to UNstage that file, I can do "git reset HEAD filename". But I have also seen instances in which the recommended command is &...
John Reed Avery's user avatar
0 votes
0 answers
114 views

I have accidentally unstaged all the changes in my branch using git reset. How to revert it?

I used git reset without any arguments and even after I committed all the changes after, the changes are still unstaged. How to revert it? I have made many changes and committed and pushed them to the ...
Guna's user avatar
  • 11
1 vote
2 answers
116 views

Git reset unexpectedly removes older commits

I am experimenting with git reset and get some results I don't understand. First lets check git log --oneline: bebf9f0 (HEAD -> main, [MyRepository]/main) Merge branch 'main' of https://github.com/[...
Frank's user avatar
  • 680
-1 votes
1 answer
411 views

Undo git pull --rebase

Sorry for bothering everyone! Please help. I wrongly used the git rebase --hard and overwrite all local files. Then I use git reflog and git reset --hard but did not find the former version! I ...
stander Qiu's user avatar
0 votes
0 answers
35 views

How to move (i.e. reset) a local git upstream tracking branch? e.g. to "undo" a `git fetch origin main`

AFAIK the only git command to manipulate upstream tracking branches is git fetch (and other commands that trigger a fetch), but they only really allow a "fast forward" operation against the ...
Kache's user avatar
  • 16.3k
-2 votes
1 answer
195 views

Git reset --hard at the beginning and there is no commit to return back [duplicate]

I just initialized .git folder to my project with git init command. It was a problem and I just wanted to make git reset --hard and try again. But reset --hard command deleted all the files that I ...
Omer Can KAPLAN's user avatar
0 votes
0 answers
287 views

What makes `git reset --hard` not getting me back to the last commit?

Starting from commit A, I did some changes on the files. Before a mass renaming*, I did commit B. After that I wanted to redo it again so I did git reset --hard. I expected it to be exactly what I got ...
Ooker's user avatar
  • 2,601
-2 votes
1 answer
62 views

git reset --hard HEAD^ removed data from local drive

I copied a project and edited it to create a new project. I made a lot of changes. After 3 months, I tried to push to the repository. Pushed to the older repository. (All code was fine and complete.) ...
Muhammad Owais's user avatar
-2 votes
1 answer
812 views

How do reset/revert a git reset HEAD~

By mistake I did a git reset HEAD~ in my branch. I see all my changed files on my local. I don't want to change anything. The branch is good as is. What do I have to do?
meez's user avatar
  • 4,492
1 vote
1 answer
157 views

git reset --hard results in a diverged branch [duplicate]

I'm working on a branch called Feature. I pushed an empty commit 'New' (Commit 1) to indicate the creation of my branch (this is the standard in my company). I then edited an important file and ...
Mr_Knightley's user avatar
-2 votes
1 answer
874 views

Git: how to reset untracked files?

I made a commit, then changed some files in my project, then did git reset --hard HEAD. It said untracked files for all the files I had added. How do I resolve this so that those files are tracked and ...
gkeenley's user avatar
  • 6,998
0 votes
1 answer
239 views

What to do after soft reset to my last commit ? Commit or pull first? or Pull then commit, or...?

I needed to discard a file of my last commit, so I soft reset it and now I can commit again but GitHub Desktop gives me the Pull origin option and I am wondering what to do: Commit and then push or ...
Alecheck's user avatar
1 vote
0 answers
39 views

Is there a way to recover removed git commits when local repository is not available?

I directly committed some changes to my GitHub repo remotely (inside the GitHub website). I then cloned this repo and did git reset --hard HEAD~3 and git push -f to go back to previous commits and ...
Pedram's user avatar
  • 11
-1 votes
2 answers
198 views

Git reset --hard without dirty

I’m trying to solve a problem where I replace my current HEAD with a specific commit by doing git reset --hard (commit), but it always ends up dirty, which I would like to remove. I need help with ...
MeepleDeMeep's user avatar
2 votes
2 answers
77 views

How to understand `in the way of writing any tracked files` in `git reset --hard`?

In git-reset, the hard mode: --hard Resets the index and working tree. Any changes to tracked files in the working tree since are discarded. Any untracked files or directories in the way of writing ...
hustnzj's user avatar
  • 695
1 vote
1 answer
299 views

cannot do hard reset with gitpython

I am using the following code using gitpython: g = git.cmd.Git(r'C:\Users\alex\Files\Repo\Scripts') g.reset('--hard') g.pull() but I get the following error: GitCommandError: Cmd('git') failed due to:...
chulo's user avatar
  • 53
0 votes
1 answer
132 views

What are the steps to do code rollback in master branch?

I am using azure devops pipeline, I need to do a code rollback in my master branch,(the code in the master branch is coming from different release, e.g release/1.0.0, release/1.0.1 and tagged.) From ...
Priyanka Sharma's user avatar
0 votes
1 answer
118 views

tried to stash using branch, how to restore without merging?

I had some temporary changes which I needed to stash so I could switch between branches without losing them. I know this is what git stash is for, but I didn't want to use it (details below for the ...
Steve Summit's user avatar
  • 46.9k
0 votes
0 answers
15 views

How is work the git reset command for overwrite local changes with remote [duplicate]

I am new in git and read some information about this command git reset --hard @{u} for resetting your local changes and overwriting them with the branch's remote changes. But I don't have a clear idea ...
Jacinto Canek's user avatar
0 votes
1 answer
271 views

GIT Reset - How to get back to specific state in repository

I have a list of commits. abc--most recent def ghi jkl mno pqr stu vwx Now I want to remove/forget the changes from abc(most recent commit) to mno. I want to do this in local as well as remote branch ...
user2645738's user avatar
1 vote
1 answer
5k views

git merge conflicts even with git reset --hard

I am working on a branch on a repository. I commit and push changes every day to origin from one computer. Then on another computer the next day I do git pull and expect the changes pushed from the ...
Engineer999's user avatar
  • 3,873

1
2 3 4 5
11