英语笔记3(git)
備注
一:?Staging Modified Files
Let’s change a file that was already tracked. (tracked 表示該文件已經被git管理過,再次修改了文件的狀態。對應狀態是untracked或not staged)
tracked n:軌道,足跡,蹤跡,小道。verb:追蹤;通過;循路而行;
二:git add (后該文件為已標記(tracked),狀態為Modified?)
git add?is a multipurpose command?—?you use it to begin tracking new files, to stage files, and to do other things like marking merge-conflicted files as resolved. It may be helpful to think of it more as “add precisely this content to the next commit” rather than “add this file to the project”.?
purpose1> 跟蹤一個新文件
purpose2> 跟蹤一個修改后的文件?
purpose3> 把合并(特指沖突)后的文件標記為已解決(有點像功能2)
參考資料:https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository
三:Ignoring Files(忽略文件)
The rules for the patterns you can put in the?.gitignore?file are as follows:
-
Blank lines or lines starting with?#?are ignored.
-
Standard glob patterns work, and will be applied recursively throughout the entire working tree.
-
You can start patterns with a forward slash (/) to avoid recursivity.
-
You can end patterns with a forward slash (/) to specify a directory.
-
You can negate a pattern by starting it with an exclamation point (!).
Glob patterns are like simplified regular expressions that shells use.
*? An asterisk (*) matches zero or more characters;?
* [abc]?matches any character inside the brackets (in this case a, b, or c);
*? a question mark (?) matches a single character;
*? and brackets enclosing characters separated by a hyphen ([0-9]) matches any character between them (in this case 0 through 9).
*? You can also use two asterisks to match nested directories;?a/**/z?would match?a/z,?a/b/z,?a/b/c/z, and so on.
四:?cover
- vt. 包括;采訪,報導(討論);涉及;行走(一段路程);掩護;翻唱
- n. 封面,封皮;蓋子;掩蔽物;幌子,借口
- vi. 覆蓋;代替;敷衍;給…投保;
eg : We’ll cover(討論)?git diff?in more detail later, but you’ll probably use it most often to answer these two questions:?
五:git diff
To see what you’ve changed but not yet staged, type?git diff?with no other arguments:
? ? git diff --stateg(--staged?and?--cached?are synonyms):
if you want to see what you’ve staged that will go into your next commit, you can use?git diff --staged. This command compares your staged changes to your last commit:
六:Viewing the Commit History(git log)
By default, with no arguments,?git log?lists the commits made in that repository in reverse chronological order; that is, the most recent commits show up first. As you can see, this command lists each commit with its SHA-1 checksum, the author’s name and email, the date written, and the commit message.
Common options to?git log
| -p | Show the patch introduced with each commit. |
| --stat | Show statistics for files modified in each commit. |
| --shortstat | Display only the changed/insertions/deletions line from the --stat command. |
| --name-only | Show the list of files modified after the commit information. |
| --name-status | Show the list of files affected with added/modified/deleted information as well. |
| --abbrev-commit | Show only the first few characters of the SHA-1 checksum instead of all 40. |
| --relative-date | Display the date in a relative format (for example, “2 weeks ago”) instead of using the full date format. |
| --graph | Display an ASCII graph of the branch and merge history beside the log output. |
| --pretty | Show commits in an alternate format. Options include oneline, short, full, fuller, and format (where you specify your own format). |
| --oneline | Shorthand for?--pretty=oneline --abbrev-commit?used together. |
七:Undoing Things
7.1? git commit?--amend
This command takes your staging area and uses it for the commit. If you’ve made no changes since your last commit (for instance, you run this command immediately after your previous commit), then your snapshot will look exactly the same, and all you’ll change is your commit message.
7.2??Unstaging a Staged File
八:Adding Remote Repositories
To add a new remote Git repository as a shortname you can reference easily, run?git remote add <shortname> <url>
九:Fetching and Pulling from Your Remotes(git fetch versus? git pull)
git fetch?
It’s important to note that the?git fetch?command only downloads the data to your local repository?—?it doesn’t automatically merge it with any of your work or modify what you’re currently working on. You have to merge it manually into your work when you’re ready.
git pull
If your current branch is set up to track a remote branch ,?you can use the?git pull?command to automatically fetch and then merge that remote branch into your current branch. This may be an easier or more comfortable workflow for you; and by default, the?git clone?command automatically sets up your local master branch to track the remote master branch (or whatever the default branch is called) on the server you cloned from. Running?git pull?generally fetches data from the server you originally cloned from and automatically tries to merge it into the code you’re currently working on.
轉載于:https://www.cnblogs.com/jinliang374003909/p/10736961.html
總結
以上是生活随笔為你收集整理的英语笔记3(git)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 如何训练孩子上厕所(初级篇)
- 下一篇: 在IDEA中关于项目java版本问题