Most Popular
1500 questions
4971
votes
22 answers
Reset local repository branch to be just like remote repository HEAD
How do I reset my local branch to be just like the branch on the remote repository?
I did:
git reset --hard HEAD
But when I run a git status,
On branch master
Changes to be committed:
(use "git reset HEAD ..." to unstage)
modified: …
hap497
- 141,763
- 43
- 79
- 93
4958
votes
37 answers
How can I add a blank directory to a Git repository?
How can I add a blank directory (that contains no files) to a Git repository?
Laurie Young
- 133,096
- 13
- 46
- 54
4954
votes
32 answers
Regular expression to match a line that doesn't contain a word
I know it's possible to match a word and then reverse the matches using other tools (e.g. grep -v). However, is it possible to match lines that do not contain a specific word, e.g. hede, using a regular…
knaser
- 1,391
- 7
- 18
- 16
4926
votes
26 answers
How to determine the URL that a local Git repository was originally cloned from?
I pulled a project from GitHub a few days ago. I have since discovered that there are several forks on GitHub, and I neglected to note which one I took originally.
How can I determine which of those forks I pulled?
Tim
- 49,551
- 3
- 18
- 19
4922
votes
69 answers
How to create a GUID / UUID
I'm trying to create globally-unique identifiers in JavaScript. I'm not sure what routines are available on all browsers, how "random" and seeded the built-in random number generator is, etc.
The GUID / UUID should be at least 32 characters and…
Jason Cohen
- 78,683
- 26
- 106
- 112
4918
votes
23 answers
Reference — What does this symbol mean in PHP?
What is this?
This is a collection of questions that come up every now and then about syntax in PHP. This is also a Community Wiki, so everyone is invited to participate in maintaining this list.
Why is this?
It used to be hard to find questions…
Gordon
- 305,248
- 71
- 524
- 547
4843
votes
128 answers
How to horizontally center an element
How can I horizontally center a
within another
using CSS?
Foo foo
Lukas
- 9,486
- 4
- 19
- 14
4769
votes
31 answers
What is the difference between a URI, a URL and a URN?
People talk about URLs, URIs, and URNs as if they're different things, but they look the same to the naked eye.
What are the distinguishable differences between them?
Sean McMains
- 56,124
- 13
- 45
- 52
4733
votes
9 answers
How to pass "Null" (a real surname!) to a SOAP web service in ActionScript 3
We have an employee whose surname is Null. Our employee lookup application is killed when that last name is used as the search term (which happens to be quite often now). The error received (thanks Fiddler!) is:
…
bill
- 26,553
- 3
- 16
- 13
4695
votes
23 answers
Accessing the index in 'for' loops
How do I access the index in a for loop?
xs = [8, 23, 45]
for x in xs:
print("item #{} = {}".format(index, x))
Desired output:
item #1 = 8
item #2 = 23
item #3 = 45
Joan Venge
- 292,935
- 205
- 455
- 667
4654
votes
13 answers
How do I exit Vim?
I am stuck and cannot escape. It says:
type :quit to quit VIM
But when I type that it simply appears in the object body.
jclancy
- 44,500
- 5
- 27
- 32
4647
votes
32 answers
How do I make a flat list out of a list of lists?
I want to flatten this list of lists:
[[1, 2, 3], [4, 5, 6], [7], [8, 9]]
into:
[1, 2, 3, 4, 5, 6, 7, 8, 9]
Emma
- 47,155
- 4
- 18
- 10
4646
votes
118 answers
How do I make the first letter of a string uppercase in JavaScript?
How do I make the first letter of a string uppercase, but not change the case of any of the other letters?
For example:
"this is a test" → "This is a test"
"the Eiffel Tower" → "The Eiffel Tower"
"/index.html" → "/index.html"
Robert Wills
- 47,133
- 3
- 16
- 6
4642
votes
41 answers
Squash my last X commits together using Git
How can I squash my last X commits together into one commit using Git?
markdorison
- 127,186
- 27
- 54
- 71
4629
votes
57 answers
How do I check if an array includes a value in JavaScript?
What is the most concise and efficient way to find out if a JavaScript array contains a value?
This is the only way I know to do it:
function contains(a, obj) {
for (var i = 0; i < a.length; i++) {
if (a[i] === obj) {
return…
brad
- 70,988
- 21
- 71
- 84