move only if file exists in a shell script
One-liner: [ -f old ] && mv old nu
One-liner: [ -f old ] && mv old nu
Angular 2 isn’t really MVC (but I suppose you can draw parallels). It is Component Based. Let me explain: Angular 1 is MVC and MVVM (MV*). Angular 1 was groundbreaking for several reasons, but one of the main reasons was because it used Dependency Injection. This was a new concept compared with other JS Frameworks … Read more
You could use the rename(1) command: rename ‘s/(.*)$/new.$1/’ original.filename Edit: If rename isn’t available and you have to rename more than one file, shell scripting can really be short and simple for this. For example, to rename all *.jpg to prefix_*.jpg in the current directory: for filename in *.jpg; do mv “$filename” “prefix_${filename}”; done; or … Read more
You need to use -M to let git autodetect the moved file when diffing. Using just git diff as knittl mentioned does not work for me. So simply: git diff -M should do it. The documentation for this switch is: -M[<n>], –find-renames[=<n>] Detect renames. If n is specified, it is a threshold on the similarity … Read more
Non-cheeky answer: git mv file2 file1 Updates the index for both old and new paths automatically. Check documentation of git mv
How about this one-liner (in bash): mkdir –parents ./some/path/; mv yourfile.txt $_ Breaking that down: mkdir –parents ./some/path # if it doesn’t work; try mkdir -p ./some/path creates the directory (including all intermediate directories), after which: mv yourfile.txt $_ moves the file to that directory ($_ expands to the last argument passed to the previous … Read more
Git detects renames rather than persisting the operation with the commit, so whether you use git mv or mv doesn’t matter. The log command takes a –follow argument that continues history before a rename operation, i.e., it searches for similar content using heuristics. To lookup the full history, use the following command: git log –follow … Read more