Posts

How do I force “git pull” to overwrite local files?

How do I force an overwrite of local files on a git pull ? The scenario is following: This is the error I'm getting: How do I force Git to overwrite them? The person is a designer - usually I resolve all the conflicts by hand, so the server has the most recent version that they just needs to update on their computer. If you have any files that are not tracked by Git (e.g. uploaded user content), these files will not be affected. I think this is the right way: Then, you have two options: OR If you are on some other branch: git fetch downloads the latest from remote without trying to merge or rebase anything. Then the git reset resets the master branch to what you just fetched. The --hard option changes all the files in your working tree to match the files in origin/master [*] : It's worth noting that it is possible to maintain current local commits by creating a branch from master before resetting: After this, all of the old commits will be kept in new-branch-to-save-curren...

What is the difference between “px”, “dip”, “dp” and “sp”?

Image
What is the difference between android units of measure? From the Android Developer Documentation: px Pixels - corresponds to actual pixels on the screen. in Inches - based on the physical size of the screen. 1 Inch = 2.54 centimeters mm Millimeters - based on the physical size of the screen. pt Points - 1/72 of an inch based on the physical size of the screen. dp or dip Density -independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Note: The compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp". sp Scale -independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommended you use this unit when speci...

How do I check out a remote Git branch?

Image
Somebody pushed a branch called test with git push origin test to a shared repository. I can see the branch with git branch -r . Now I'm trying to check out the remote test branch. I've tried: git checkout test which does nothing git checkout origin/test gives * (no branch) . Which is confusing. How can I be on "no branch"? How do I check out a remote Git branch? Jakub's answer actually improves on this. With Git versions ≥ 1.6.6, you can just do: (User masukomi points out below that git checkout test will NOT work in modern git if you have multiple remotes. In this case use git checkout -b test <name of remote>/test ). Before you can start working locally on a remote branch, you need to fetch it as called out in answers below. To fetch a branch, you simply need to: This will fetch all of the remote branches for you. You can see the branches available for checkout with: With the remote branches in hand, you now need to check out the branch you are int...

What is the difference between String and string in C#?

Image
Example ( note the case ): What are the guidelines for the use of each? And what are the differences ? string is an alias in C# for System.String . So technically, there is no difference. It's like int vs. System.Int32 . As far as guidelines, it's generally recommended to use string any time you're referring to an object. e.g. Likewise, I think it's generally recommended to use String if you need to refer specifically to the class. e.g. This is the style that Microsoft tends to use in their examples. It appears that the guidance in this area may have changed, as StyleCop now enforces the use of the C# specific aliases. Just for the sake of completeness, here's a brain dump of related information... As others have noted, string is an alias for System.String . They compile to the same code, so at execution time there is no difference whatsoever. This is just one of the aliases in C#. The complete list is: Apart from string and object , the aliases are all t...

Which equals operator (== vs ===) should be used in JavaScript comparisons?

Image
I'm using JSLint to go through JavaScript, and it's returning many suggestions to replace == (two equals signs) with === (three equals signs) when doing things like comparing idSele_UNVEHtype.value.length == 0 inside of an if statement. Is there a performance benefit to replacing == with === ? Any performance improvement would be welcomed as many comparison operators exist. If no type conversion takes place, would there be a performance gain over == ? The identity ( === ) operator behaves identically to the equality ( == ) operator except no type conversion is done, and the types must be the same to be considered equal. Reference: Javascript Tutorial: Comparison Operators The == operator will compare for equality after doing any necessary type conversions . The === operator will not do the conversion, so if two values are not the same type === will simply return false . Both are equally quick. To quote Douglas Crockford's excellent JavaScript: The Good Parts, Java...