Questions tagged [reset]

Resetting something restores it to a default position or value, or to a previous position or value

Resetting something restores it to a default position or value, or to a previous position or value

2384 questions
779
votes
7 answers

In plain English, what does "git reset" do?

I have seen interesting posts explaining subtleties about git reset. Unfortunately, the more I read about it, the more it appears that I don't understand it fully. I come from a SVN background and Git is a whole new paradigm. I got mercurial easily,…
Bite code
  • 578,959
  • 113
  • 301
  • 329
396
votes
18 answers

Reset auto increment counter in postgres

I would like to force the auto increment field of a table to some value, I tried with this: ALTER TABLE product AUTO_INCREMENT = 1453 AND ALTER SEQUENCE product RESTART WITH 1453; ERROR: relation "your_sequence_name" does not exist I have a…
Rad
  • 4,403
  • 4
  • 24
  • 25
362
votes
16 answers

How to reset a form using jQuery with .reset() method

I had working code that could reset my form when I click on a reset button. However after my code is getting longer, I realize that it doesn't work anymore.
yvonnezoe
  • 7,129
  • 8
  • 30
  • 47
354
votes
31 answers

Resetting a multi-stage form with jQuery

I have a form with a standard reset button coded thusly: Trouble is, said form is of the multi-stage sort, so if a user fills out a stage & then returns later, the 'remembered' values for…
da5id
  • 9,100
  • 9
  • 39
  • 53
293
votes
10 answers

How to git reset --hard a subdirectory

UPDATE²: With Git 2.23 (August 2019), there's a new command git restore that does this, see the accepted answer. UPDATE: This will work more intuitively as of Git 1.8.3, see my own answer. Imagine the following use case: I want to get rid of all…
krlmlr
  • 25,056
  • 14
  • 120
  • 217
260
votes
7 answers

Fastest way to reset every value of std::vector to 0

What's the fastest way to reset every value of a std::vector to 0 and keeping the vectors initial size ? A for loop with the [] operator ?
Matthieu Riegler
  • 31,918
  • 20
  • 95
  • 134
132
votes
11 answers

How to reset db in Django? I get a command 'reset' not found error

Following this Django by Example tutotrial here: http://lightbird.net/dbe/todo_list.html The tutorial says: "This changes our table layout and we’ll have to ask Django to reset and recreate tables: manage.py reset todo; manage.py syncdb" though,…
Prem
  • 3,373
  • 7
  • 29
  • 43
122
votes
4 answers

How to reuse an ostringstream?

I'd like to clear out and reuse an ostringstream (and the underlying buffer) so that my app doesn't have to do as many allocations. How do I reset the object to its initial state?
twk
  • 16,760
  • 23
  • 73
  • 97
115
votes
3 answers

How do I reset the setInterval timer?

How do I reset a setInterval timer back to 0? var myTimer = setInterval(function() { console.log('idle'); }, 4000); I tried clearInterval(myTimer) but that completely stops the interval. I want it to restart from 0.
Rik de Vos
  • 3,467
  • 5
  • 28
  • 34
108
votes
2 answers

How to rollback the two previous commits?

Consider this scenario: Developer A does a commit: #n Dev. B does commit #n+1 Dev. A does commit #n+2 and commit #n+3 and then discovers that in his commit #n+2 he introduced a defect. How can dev. A rollback his last 2 commits and continue…
Marius Butuc
  • 17,781
  • 22
  • 77
  • 111
108
votes
6 answers

Reset PostgreSQL primary key to 1

Is there a way to reset the primary key of a PostgreSQL table to start at 1 again on a populated table? Right now it's generating numbers from 1000000 and up. I want it all to reset and start to 1, keeping all my existing data intact.
David
  • 4,235
  • 12
  • 44
  • 52
99
votes
4 answers

How can I uncommit the last commit in a git bare repository?

Taking into consideration that there are several git commands that make no sense in a bare repository (because bare repositories don't use indexes and do not have a working directory), git reset --hard HEAD^ is not a solution to uncommit the last…
96
votes
4 answers

C++11 When clearing shared_ptr, should I use reset or set to nullptr?

I have a question about C++11 best practices. When clearing a shared_ptr, should I use the reset() function with no parameter, or should I set the shared_ptr to nullptr? For example: std::shared_ptr foo(new…
user1930581
  • 1,465
  • 1
  • 13
  • 23
84
votes
6 answers

Git: How to move back and forth between commits

I have a newbie question about Git: I need to move back and forth in a history of a branch. That means, I need to get all the files to the state they were in in some old revision, and then I need to get back to the latest state in the repository. I…
Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277
76
votes
3 answers

How to reset par(mfrow) in R

I set par(mfrow =c(1,2)) and now everytime I plot it shows splits it into 2 plots. How can I reset this to only show one plot. Thanks so much.
akz
  • 1,865
  • 2
  • 16
  • 13
1
2 3
99 100