2012年1月31日 星期二

[Linux 命令] dd : binary 讀取與寫入

前言 : 
dd 指令最大的功效應該是在於『備份』啊! 因為 dd 可以讀取磁碟裝置的內容(幾乎是直接讀取磁區"sector"),然後將整個裝置備份成一個檔案呢!真的是相當的好用啊~ dd 的用途有很多啦~但是這裡僅講一些比較重要的選項,如下 : 
- if=file : 就是 input file 囉~也可以是裝置. 預設是標準輸入.
- of=file : 就是 output file 喔~也可以是裝置. 預設為表準輸出.
- ibs=b : 一次讀入 b 個 bytes. (default: 512)
- obs=bytes : 一次寫入 b 個 bytes. (default: 512)
- bs=b : 規劃的一個 block 的大小,若未指定則預設是 512 bytes. 等於同時設置 ibs 與 obs. (一個 sector 的大小)
- skip=blocks : 從輸入文件跳過 blocks 個區塊後, 再開始進行複製.
- seek=blocks : 從輸出文件跳過 blocks 個區塊後, 再開始進行複製. (通常只有當輸出為磁碟或裝置才有用)
- count=blocks : 僅拷貝 blocks 個區塊. 區塊的大小可以由 ibs 或 bs 設置.

實例介紹 : 
- 整盘数据备份与恢复 
可以使用下面命令 "備份" /dev/hdx 到 /dev/hdy : 
# dd if=/dev/hdx of=/dev/hdy

使用下面命令 "備份" /dev/hdx 並用 gzip 壓縮後存到 /path/to/image.gz : 
# dd if=/dev/hdx | gzip >/path/to/image.gz

使用下面命令 "還原" /path/to/image.gz 到 /dev/hdx : 
# gzip -dc /path/to/image.gz | dd of=/dev/hdx

- 備份MBR 
使用下面命令 "備份" 磁盤開頭 512 bytes 的 MBR 到 /path/to/image : 
# dd if=/dev/hdx of=/path/to/image count=1 bs=512

使用下面命令將剛剛備份的 MBR "還原" 到指定磁盤 : 
# dd if=/path/to/image of=/dev/hdx

- 拷貝内存資料到硬碟 
使用下面命令將內存資料複製到 /root/mem.bin : 
# dd if=/dev/mem of=/root/mem.bin bs=1024

- 從光碟拷貝 iso 映像檔 
使用下面命令將 光碟內容 "拷貝" 到 /root/cd.iso : 
# dd if=/dev/cdrom of=/root/cd.iso

- 修复硬碟 
當硬盤較長時間(比如1,2年)放置不使用後,磁盤上會產生magnetic flux point。當磁頭讀到這些區域時會遇到困難,並可能導致I/O錯誤。當這種情況影響到硬盤的第一個扇區時,可能導致硬盤報廢。上邊的命令有可能使這些數據起死回生。且這個過程是安全,高效的 : 
# dd if=/dev/sda of=/dev/sda

- binary 檔案的讀取 
考慮你有一個 binary 的檔案 test.bin, 假設你想要 skip 前面的 10 bytes, 並讀取接下來的 10 bytes, 則你可以這麼做 : 
$ hexdump -Cv test.bin # 以 hex 讀取 test.bin
00000000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |................|
00000010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f |................|
00000020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f | !"#$%&'()*+,-./|
00000030 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f |0123456789:;<=>?|
00000040 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f |@ABCDEFGHIJKLMNO|
00000050 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f |PQRSTUVWXYZ[\]^_|
00000060 60 61 62 63 64 |`abcd|
00000065
$ dd if=test.bin bs=1 count=10 skip=10 of=out.bin # 從第11個 byte 開始連續讀 10 個 byte. 記得設定 bs=1 說明 count 一次為一個 byte
10+0 records in
10+0 records out
10 bytes (10 B) copied, 0.000508929 s, 19.6 kB/s
$ hexdump -Cv out.bin # 以 hex 檢視輸出結果
00000000 0a 0b 0c 0d 0e 0f 10 11 12 13 |..........|
0000000a

補充說明 : 
linux dd命令参数及用法详解 
鳥哥Linux 私房菜 : 特殊裝置 loop 掛載 (映象檔不燒錄就掛載使用) 
想像一下如果今天我們從國家高速網路中心(http://ftp.twaren.net)或者是義守大學(http://ftp.isu.edu.tw)下載了 Linux 或者是其他所需光碟/DVD的映象檔後, 難道一定需要燒錄成為光碟才能夠使用該檔案裡面的資料嗎?當然不是啦!我們可以透過 loop 裝置來掛載的...

新手看招:Linux作業系統下的dd命令技巧 
鳥哥 Linux 私房菜 : 檔案與檔案系統的壓縮與打包 - dd

2012年1月30日 星期一

[Quick Python] 5. Lists, tuples, and sets - Part 2

Tuples : 
Tuples are data structures that are very similar to lists, but they can’t be modified. They can only be created. Tuples are so much like lists that you may wonder why Python bothers to include them. The reason is that tuples have important roles that can’t be efficiently filled by lists, as keys for dictionaries. 

- Tuple basics 
Creating a tuple is similar to creating a list: assign a sequence of values to a variable. A list is a sequence that is enclosed by [ and ]; a tuple is a sequence that is enclosed by ( and ). For example : 
>>> x = ('a', 'b', 'c') # This line creates a three-element tuple.

After a tuple is created, using it is so much like using a list that it’s easy to forget they’re different data types : 
 

The main difference between tuples and lists is that tuples are immutable. An attempt to modify a tuple results in a confusing error message, which is Python’s way of saying it doesn’t know how to set an item in a tuple : 
>>> x[2] = 'd'
Traceback (most recent call last):
File "", line 1, in
TypeError: 'tuple' object does not support item assignment

You can create tuples from existing ones by using the + and * operators : 
>>> x + x
('a', 'b', 'c', 'a', 'b', 'c')
>>> x * 2
('a', 'b', 'c', 'a', 'b', 'c')

A copy of a tuple can be made in any of the same ways as for lists : 
>>> x[:]
('a', 'b', 'c')
>>> x * 1
('a', 'b', 'c')
>>> x + ()
('a', 'b', 'c')

Tuples themselves can’t be modified. But if they contain any mutable objects (for example, lists or dictionaries), these may be changed if they’re still assigned to their own variables. Tuples that contain mutable objects aren’t allowed as keys for dictionaries. 

- One-element tuples need a comma 
A small syntactical point is associated with using tuples. Because the square brackets used to enclose a list aren’t used elsewhere in Python, it’s clear that [] means an empty list and [1] means a list with one element. The same thing isn’t true with the parentheses used to enclose tuples. Parentheses can also be used to group items in expressions in order to force a certain evaluation order. If we say (x + y) in a Python program, do we mean that x and y should be added and then put into a one-element tuple, or do we mean that the parentheses should be used to force x and y to be added, before any expressions to either side come into play

This is only a problem for tuples with one element, because tuples with more than one element always include commas to separate the elements, and the commas tell Python the parentheses indicate a tuple, not a grouping. In the case of one-element tuples, Python requires that the element in the tuple be followed by a comma, to disambiguate the situation. In the case of zero-element (empty) tuples, there’s no problem. An empty set of parentheses must be a tuple, because it’s meaningless otherwise : 
 

- Packing and unpacking tuples 
As a convenience, Python permits tuples to appear on the left-hand side of an assignment operator, in which case variables in the tuple receive the corresponding values from the tuple on the right-hand side of the assignment operator. Here’s a simple example : 
>>> (one, two, three, four) = (1, 2, 3, 4)
>>> one
1
>>> two
2

This can be written even more simply, because Python recognizes tuples in an assignment context even without the enclosing parentheses. The values on the right-hand side are packed into a tuple and then unpacked into the variables on the left-hand side : 
>>> one, two, three, four = 1, 2, 3, 4

This is a convenient way to swap values between variables. Instead of saying : 
temp = var1
var1 = var2
var2 = temp

just say : 
var1, var2 = var2, var1

To make things even more convenient, Python 3 has an extended unpacking feature, allowing an element marked with a * to absorb any number elements not matching the other elements. Again, some examples will make this clearer : 
 

Note that the starred element receives all the surplus items as a list, and that if there are no surplus elements, it receives an empty list. Packing and unpacking can be performed using list delimiters as well : 
 

- Converting between lists and tuples 
Tuples can be easily converted to lists with the list() function (which takes any sequence as an argument and produces a new list with the same elements as the original sequence). Similarly, lists can be converted to tuples with the tuple() function (which does the same thing but produces a new tuple instead of a new list) : 
>>> list((1, 2, 3, 4))
[1, 2, 3, 4]
>>> tuple([1, 2, 3, 4])
(1, 2, 3, 4)

As an interesting side note, list() is a convenient way to break a string into characters : 
>>> list("Hello")
['H', 'e', 'l', 'l', 'o']

This works because list() (and tuple()) apply to any Python sequence, and a string is just a sequence of characters. 

Sets : 
set in Python is an unordered collection of objects used in situations where membership and uniqueness in the set are main things you need to know about that object. Just as with dictionary keys, the items in a set must be immutable and hashable. This means that ints, floats, strings, and tuples can be members of a set, but lists, dictionaries, and sets themselves can’t. 

- Set operations 
In addition to the operations that apply to collections in general, like inlen, and being able to use a for loop to iterate over all of their elements, sets also have several set-specific operations : 
 

You can create a set by using set on a sequence, like a list (1). When a sequence is made into a set, duplicates are removed (2). After creating a set using the set function, you can use add (3) and remove (4) to change the elements in the set. The in keyword is used to check for membership of an object in a set (5). You can also use | (6) to get the union, or combination, of two sets, & to get their intersection (7), and ^ (8) tofind their symmetric difference—that is, elements that are in one set or the other but not both. 

These examples aren’t a complete listing of set operations but are enough to give you a good idea of how sets work. For more information, refer to the official Python documentation. 

- Frozensets 
Because sets aren’t immutable and hashable, they can’t belong to other sets. To remedy that situation there is another set type, frozenset (by built-in frozenset()), which is just like a set but can’t be changed after creation. Because frozensets are immutable and hashable, they can be members of other sets : 
 

Supplement : 
[Python 學習筆記] 起步走 : 內建型態與操作 (Tuple) 
[Python 學習筆記] 起步走 : 內建型態與操作 (集合)

[Quick Python] 5. Lists, tuples, and sets - Part 1

Preface : 
In this chapter, we’ll discuss the two major Python sequence types: lists and tuples. At first, lists may remind you of arrays in many other languages, but don’t be 
fooled—lists are a good deal more flexible and powerful than plain arrays. This chapter also discusses a newer Python collection type: sets. Sets are useful when an object’s membership in the collection, as opposed to its position, is important. 

Tuples are like lists that can’t be modified—you can think of them as a restricted type of list or as a basic record type. We’ll discuss why we need such a restricted data type later in the chapter. Most of the chapter is devoted to lists, because if you understand lists, you pretty much understand tuples. The last part of the chapter discusses the differences between lists and tuples, in both functional and design terms. So this chapter covers : 
* Manipulating lists and list indices
* Modifying lists
* Sorting
* Using common list operations
* Handling nested lists and deep copies
* Using tuples
* Creating and using sets

Lists are like arrays : 
A list in Python is much the same thing as an array in Java or C or any other language. It’s an ordered collection of objects. You create a listd by enclosing a comma separated list of elements in square brackets, like so : 
# This assigns a three-element list to x
x = [1, 2, 3]

Note that you don’t have to worry about declaring the list or fixing its size ahead of time. This line creates the list as well as assigns it, and a list automatically grows or shrinks in size as needed. But if you do want to use array like in C or Java, refer to below text : 
 

Unlike lists in many other languages, Python lists can contain different types of elements; a list element can be any Python object. Probably the most basic built-in list function is the len function, which returns the number of elements in a list : 
 
(Note that the len function doesn’t count the items in the inner, nested list.

List indices : 
Elements can be extracted from a Python list using a notation like C’s array indexing. Like C and many other languages, Python starts counting from 0; asking for element 0 returns the first element of the list, asking for element 1 returns the second element, and so forth. Here are a few examples : 
>>> x = ["first", "second", "third", "fourth"]
>>> x[0]
'first'
>>> x[2]
'third'

But Python indexing is more flexible than C indexing; if indices are negative numbers, they indicate positions counting from the end of the list, with –1 being the last position in the list, –2 being the second-to-last position, and so forth. Continuing with the same list x, we can do the following : 
>>> a = x[-1]
>>> a
'fourth'
>>> x[-2]
'third'

Python can extract or assign to an entire sublist at once, an operation known as slicing. Instead of entering list[index] to extract the item just after index, enterlist[index1:index2] to extract all items including index1 and up to (but not includingindex2 into a new list. Here are some examples : 
 

It may seem reasonable that if the second index indicates a position in the list before the first index, this would return the elements between those indices in reverse order, but this isn’t what happens. Instead, this return: an empty list : 
>>> x[-1:2] # -1 means 3 here. So equals x[3:2] which first index is after second index.
[]

When slicing a list, it’s also possible to leave out index1 or index2. Leaving out index1 means “go from the beginning of the list,” and leaving out index2 means “go to the end of the list” : 
>>> x[:3] # From 0~2
['first', 'second', 'third']
>>> x[2:] # From 2~3
['third', 'fourth']

Omitting both indices makes a new list that goes from the beginning to the end of the original list; that is, it copies the list. This is useful when you wish to make a copy that you can modify, without affecting the original list : 
 

Modifying lists : 
You can use list index notation to modify a list as well as to extract an element from it. Put the index on the left side of the assignment operator : 
>>> x = [1, 2, 3, 4]
>>> x[1] = "two"
>>> x
[1, 'two', 3, 4]

Slice notation can be used here too. Saying something like lista[index1:index2] = listb causes all elements of lista between index1 and index2 to be replaced with the elements in listblistb can have more or fewer elements than are removed from lista, in which case the length of lista will be altered. You can use slice assignment to do a number of different things, as shown here : 
 

Appending a single element to a list is such a common operation that there’s a special append method to do it : 
>>> x = [1, 2, 3]
>>> x.append("four")
>>> x
[1, 2, 3, 'four']

One problem can occur if you try to append one list to another. The list gets appended as a single element of the main list : 
 

The extend method is like the append method, except that it allows you to add one list to another : 
 

There is also a special insert method to insert new list elements between two existing elements or at the front of the list. insert is used as a method of lists and takes two additional arguments; the first is the index position in the list where the new element should be inserted, and the second is the new element itself : 
 

insert understands list indices as discussed in the section on slice notation, but for most uses it’s easiest to think of list.insert(n, elem) as meaning insert elem just before the nth element of list. insert is just a convenience method. Anything that can be done with insert can also be done using slice assignment; that is, list.insert(n, elem) is the same thing as list[n:n] = [elem] when n is nonnegative. Using insert makes for somewhat more readable code, and insert even handles negative indices : 
>>> x = [1, 2, 3]
>>> x.insert(-1, "hello") # insert value before last value (-1)
>>> print(x)
[1, 2, 'hello', 3]

The del statement is the preferred method of deleting list items or slices : 
>>> x = ['a', 2, 'c', 7, 9, 11]
>>> del x[1]
>>> x
['a', 'c', 7, 9, 11]
>>> del x[:2]
>>> x
[7, 9, 11]

In general, del list[n] does the same thing as list[n:n+1] = [], whereas del list[m:n] does the same thing as list[m:n] = []

The remove method isn’t the converse of insert. Whereas insert inserts an element at a specified location, remove looks for the first instance of a given value in a list and removes that value from the list : 
 

If remove can’t find anything to remove, it raises an error. You can catch this error using the exception-handling abilities of Python, or you can avoid the problem by usingin to check for the presence of something in a list before attempting to remove it. 
 

The reverse method is a more specialized list modification method. It efficiently reverses a list in place : 
>>> x = [1, 3, 5, 6, 7]
>>> x.reverse()
>>> x
[7, 6, 5, 3, 1]

Sorting lists : 
Lists can be sorted using the built-in Python sort method : 
>>> x = [3, 8, 4, 0, 2, 1]
>>> x.sort()
>>> x
[0, 1, 2, 3, 4, 8]

This does an in-place sort—that is, it changes the list being sorted. To sort a list without changing the original list, make a copy of it first : 
>>> x = [2, 4, 1, 3]
>>> y = x[:]
>>> y.sort()
>>> y
[1, 2, 3, 4]
>>> x
[2, 4, 1, 3]

The sort method can sort just about anything, because Python can compare just about anything. But there is one caveat in sorting. The default key method used by sort requires that all items in the list be of comparable types. That means that using the sort method on a list containing both numbers and strings will raise an exception : 
>>> x = [1, 2, 'hello', 3]
>>> x.sort()
Traceback (most recent call last):
File "", line 1, in
TypeError: unorderable types: str() < int()

On the other hand, we can sort a list of lists : 
>>> x = [[3, 5], [2, 9], [2, 3], [4, 1], [3, 2]]
>>> x.sort()
>>> x
[[2, 3], [2, 9], [3, 2], [3, 5], [4, 1]]

According to the built-in Python rules for comparing complex objects, the sublists are sorted first by ascending first element and then by ascending second element. sort is even more flexible than this—it’s possible to use your own key function to determine how elements of a list are sorted. 

- Custom sorting 
To use custom sorting, you need to be able to define functions, something we haven’t talked about. In this section we’ll also use the fact that len(string) returns the number of characters in a string. String operations are discussed more fully in chapter 6. 

By default, sort uses built-in Python comparison functions to determine ordering, which is satisfactory for most purposes. There will be times, though, when you want to sort a list in a way that doesn’t correspond to this default ordering. For example, let’s say we wish to sort a list of words by the number of characters in each word, in contrast to the lexicographic sort that would normally be carried out by Python. 

To do this, write a function that will return the value, or key, that we want to sort on, and use it with the sort method. That function in the context of sort is a function that takes one argument and returns the key or value the sort function is to use. For our number-of-characters ordering, a suitable key function could be : 
  1. def compare_num_of_chars(string1):  
  2.     return len(string1)  
This key function is trivial. It passes the length of each string back to the sort method, rather than the strings themselves. After you define the key function, using it is a matter of passing it to the sort method using the key keyword. Because functions are Python objects, they can be passed around like any other Python object. Here’s a small program that illustrates the difference between a default sort and our custom sort : 
 
The first list is in lexicographic order (with uppercase coming before lowercase), and the second list is ordered by ascending number of characters. 

Custom sorting is very useful, but if performance is critical, it may be slower than the default. Usually this impact is minimal, but if the key function is particularly complex, the effect may be more than desired, especially for sorts involving hundreds of thousands or millions of elements. 

One particular place to avoid custom sorts is where you want to sort a list in descending, rather than ascending, order. In this case, use the sort method’s reverseparameter set to True. If for some reason you don’t want to do that, it’s still better to sort the list normally and then use the reverse method to invert the order of the resulting list. These two operations together—the standard sort and the reverse—will still be much faster than a custom sort. 

- The sorted() function 
Lists have a built-in method to sort themselves, but other iterables in Python, like the keys of a dictionary, for example, don’t have a sort method. Python also has the builtin function sorted(), which returns a sorted list from any iterable. sorted() uses the same key and reverse parameters as the sort method : 
>>> x = (4, 3, 1, 2)
>>> y = sorted(x)
>>> y
[1, 2, 3, 4]
>>> x # The original iterable object isn't change
(4, 3, 1, 2)

Other common list operations : 
A number of other list methods are frequently useful, but they don’t fall into any specific category. 

- List membership with the in operator 
It’s easy to test if a value is in a list using the in operator, which returns a Boolean value. You can also use the converse, the not in operator : 
 

- List concatenation with the + operator 
To create a list by concatenating two existing lists, use the + (list concatenation) operator. This will leave the argument lists unchanged : 
>>> z = [1, 2, 3] + [3, 4, 5]
>>> z
[1, 2, 3, 3, 4, 5]

- List initialization with the * operator 
Use the * operator to produce a list of a given size, which is initialized to a given value. This is a common operation for working with large lists whose size is known ahead of time. Although you can use append to add elements and automatically expand the list as needed, you obtain greater efficiency by using * to correctly size the list at the start of the program : 
>>> z = [None] * 4
>>> z
[None, None, None, None]

When used with lists in this manner, * (which in this context is called the list multiplication operator) replicates the given list the indicated number of times and joins all the copies to form a new list. This is the standard Python method for defining a list of a given size ahead of time. A list containing a single instance of None is commonly used in list multiplication, but the list can be anything : 
>>> z = [3, 1] * 2
>>> z
[3, 1, 3, 1]

- List minimum or maximum with min and max 
You can use min() and max() to find the smallest and largest elements in a list. You’ll probably use these mostly with numerical lists, but they can be used with lists containing any type of element. Trying to find the maximum or minimum object in a set of objects of different types causes an error if it doesn’t make sense to compare those types : 
>>> min([3, 7, 0, -2, 11])
-2
>>> max([4, "Hello", [1, 2]])
Traceback (most recent call last):
File "", line 1, in
TypeError: unorderable types: str() > int()

- List search with index 
If you wish to find where in a list a value can be found (rather than wanting to know only if the value is in the list), use the index method. It searches through a list looking for a list element equivalent to a given value and returns the position of that list element : 
>>> x = [1, 3, "five", 7, -2]
>>> x.index("five")
2
>>> x.index(5)
Traceback (most recent call last):
File "", line 1, in
ValueError: 5 is not in list

Attempting to find the position of an element that doesn’t exist in the list at all raises an error, as shown here. This can be handled in the same manner as the analogous error that can occur with the remove method (that is, by testing the list with in before using index). 

- List matches with count 
count also searches through a list, looking for a given value, but it returns the number of times that value is found in the list rather than positional information : 
>>> x = [1, 2, 2, 3, 5, 2, 5]
>>> x.count(2)
3
>>> x.count(5)
2
>>> x.count(4)
0

- Summary of list operations 
You can see that lists are very powerful data structures, with possibilities that go far beyond plain old arrays. List operations are so important in Python programming that it’s worth laying them out for easy reference, as shown in table 5.1 : 
 

Nested lists and deep copies : 
This is another advanced topic that you may want to skip if you’re just learning the language. Lists can be nested. One application of this is to represent two-dimensional matrices. The members of these can be referred to using two-dimensional indices. Indices for these work as follows : 
>>> m = [[0, 1, 2], [10, 11, 12], [20, 21, 22]]
>>> m[0]
[0, 1, 2]
>>> m[0][1]
1
>>> m[2][2]
22

This mechanism scales to higher dimensions in the manner you would expect. Most of the time, this is all you need to concern yourself with. But there is an issue 
with nested lists that you may run into. This is the result of the combination of the way variables refer to objects and the fact that some objects (such as lists) can be modified (they’re mutable). An example is the best way to illustrate : 
>>> nested = [0]
>>> original = [nested, 1]
>>> original
[[0], 1]

Figure 5.1 shows what this looks like : 
 

The value in the nested list can now be changed using either the nested or the original variables : 
>>> nested[0] = 'zero'
>>> original
[['zero'], 1]
>>> original[0][0] = 0
>>> nested
[0]
>>> original
[[0], 1]

But if nested is set to another list, the connection between them is broken : 
>>> nested = [2] # Assign variable nested to another list
>>> original
[[0], 1] # The variable original still link to [0] not [2]

Figure 5.2 illustrates this : 
 
Figure 5.2 The first item of the original list is still a nested list, but the nested variable refers to a different list. 

You’ve seen that you can obtain a copy of a list by taking a full slice (that is, x[:]). You can also obtain a copy of a list using the + or * operator (for example, x + [] or x * 1). These are slightly less efficient than the slice method. All three create what is called a shallow copy of the list. This is probably what you want most of the time. But if your list has other lists nested in it, you may want to make a deep copy. You can do this with the deepcopy function of the copy module : 
>>> original = [[0], 1]
>>> shallow = original[:]
>>> import copy
>>> deep = copy.deepcopy(original)
>>> original[0][0]=1
>>> shallow
[[1], 1]
>>> deep
[[0], 1]

See figure 5.3 for an illustration : 
 
Figure 5.3 A shallow copy doesn’t copy nested lists. 

The deep copy is independent of the original, and no change to it has any effect on the original list: 

Supplement : 
[Quick Python] 5. Lists, tuples, and sets - Part 2 
[Python 學習筆記] 起步走 : 內建型態與操作 (串列)

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...