This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git diff two files in different branches | |
D:\pathofrepo>git diff origin/branch1 origin/branch2 -- pathtofile/filename.cs | |
if you want to ignore white spaces | |
git diff -b origin/branch1 origin/branch2 -- pathtofile/filename.cs | |
reference: | |
https://stackoverflow.com/questions/4350678/git-diff-w-ignore-whitespace-only-at-start-end-of-lines |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git whatchanged --name-only --pretty="" *.xaml *.cs | |
or | |
git whatchanged --oneline --name-only | |
https://stackoverflow.com/questions/25289469/how-to-find-list-of-unique-files-that-have-changed | |
https://stackoverflow.com/questions/10641361/get-all-files-that-have-been-modified-in-git-branch | |
find list of unique files that changed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://stackoverflow.com/questions/35978550/how-to-show-uncommitted-changes-in-git-and-some-git-diffs-in-detail | |
git diff | |
https://stackoverflow.com/questions/8554776/how-to-filter-git-diff-based-on-file-extensions | |
git diff -- '***.py' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git checkout <branch-name> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Refernce: https://stackoverflow.com/questions/1146973/how-do-i-revert-all-local-changes-in-git-managed-project-to-previous-state | |
#!/bin/sh | |
git reset --hard | |
git clean -f -d | |
git checkout HEAD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git rev-parse --abbrev-ref HEAD | |
or with Git 2.22 and above: | |
git branch --show-current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Desc: Array Split | |
//Say you have an array (or list) of arbitrary integers. | |
//The data structure must be reordered so that all values less than a | |
//special reference value are placed on the left. All values greater than | |
//or equal to the reference value are placed on the right. | |
//The ordering within the subranges is not relevant and may vary. | |
//Input Reference element Sample result | |
//[4, 7, 1, 20] 9 [1, 4, 7, 9, 20] | |
//[3, 5, 2] 7 [2, 3, 5, 7] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Add One to an Array as a Number | |
//Input Result | |
//[1, 3, 2, 4] [1, 3, 2, 5] | |
//[1, 4, 8, 9] [1, 4, 9, 0] | |
//[9, 9, 9, 9] [1, 0, 0, 0, 0] | |
var lst = new List<int> { 1, 4, 8, 9 }; | |
var one = 1; | |
var revlst = lst.ToArray().Reverse().ToList(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Palindrome Lists | |
//Input Result | |
//[“One”, “Test”, “ – ”, “Test”, “One”] True | |
//[“Max”, “Mike”, “Mike”, “Max”] True | |
//[“Tim”, “Tom”, “Mike”, “Max”] False | |
//var lst = new List<string>() { "One", "Test", "–", "Test", "One" }; | |
var lst = new List<string>() { "Max", "Mike", "Mike", "Max"}; | |
var cnt = lst.Count()/2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//even before odd numbers | |
//Input Result | |
//[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [2, 4, 6, 8, 10, 3, 7, 1, 9, 5] | |
//[2, 4, 6, 1, 8] [2, 4, 6, 8, 1] | |
//[2, 4, 6, 8, 1] [2, 4, 6, 8, 1] | |
var lst = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; | |
var lstEven = new List<int>(); | |
var lstOdd = new List<int>(); |
NewerOlder