git 颜色扩展_GIT:扩展
git 顏色擴展
Nearly every VCS has some form of branching support. Branching means, you diverge from the main line of development and continue to do work without messing with that main line. In many VCS tools, this is a somewhat expensive process, often requiring you to create a new copy of your source code directory, which can take a long time for large projects.
幾乎每個VCS都具有某種形式的分支支持。 Branching意味著,您脫離了開發(fā)的主線,并且繼續(xù)進行工作而不會弄亂主線。 在許多VCS工具中,這是一個比較昂貴的過程,通常需要您創(chuàng)建源代碼目錄的新副本,這對于大型項目可能會花費很長時間。
Consider a tree for example. A tree always has some branches along with the large trunk. Similarly, branches in Git are smaller parts of the project which need not interfere with the main branch (recall master). They have their own commits and are added to master once they are completed. The master branch is like the trunk of a tree. In most cases, the code contained in the master branch is usually the one being deployed.
考慮一棵樹。 一棵樹總是與大樹干一起有一些樹枝。 同樣,Git中的分支是項目的較小部分,不需要干擾主分支(調(diào)用主分支)。 它們具有自己的提交,并在完成后被添加到母版中。 主分支就像一棵樹的樹干。 在大多數(shù)情況下,master分支中包含的代碼通常是正在部署的代碼。
Some people refer to Git's branching model as its "killer feature", and it certainly lets Git apart in the VCS community. Why is it so special? Git branches are incredibly lightweight, making branching operations nearly instantaneous, and switching back and forth between branches generally just as fast. Unlike many other VCSs, Git encourages workflows that branch and merge often, even multiple times in a day. Understanding and mastering this feature gives you a powerful and unique tool and can entirely change the way that you develop.
有人將Git的分支模型稱為其"killer feature" ,它肯定會使Git在VCS社區(qū)中脫穎而出。 為什么這么特別? Git分支非常輕巧,幾乎可以立即進行分支操作,并且在分支之間來回切換的速度通常一樣快。 與許多其他VCS不同,Git鼓勵工作流經(jīng)常分支和合并,甚至在一天內(nèi)多次。 了解和掌握此功能可以為您提供強大而獨特的工具,并且可以完全改變您的開發(fā)方式。
Let's consider that our awesome_project is based on a Web Development Project. You are currently on the master branch and it's going great, but you need to add a sign-in feature to your project. Now you certainly don't want this code to mess with your current code, do you? So let's give the feature its own branch. You create a new branch by using git branch command. Check the status of the repository to make sure you don't have anything to commit.
讓我們考慮一下我們的awesome_project基于Web開發(fā)項目。 您目前位于master分支上,并且進展順利,但是您需要在項目中添加登錄功能。 現(xiàn)在您當(dāng)然不希望此代碼與您當(dāng)前的代碼混淆,是嗎? 因此,讓我們?yōu)楣δ芴峁┳约旱姆种А?您可以使用git branch命令創(chuàng)建一個新分支。 檢查存儲庫的狀態(tài),以確保您沒有要提交的任何內(nèi)容。
Name the new branch signin_feature: $ git branch signin_feature
將新分支命名$ git branch signin_feature signin_feature: $ git branch signin_feature
Check the status again. Hmm, we're still on the master branch. How do we switch to our new branch? Remember our friend from before, git checkout? This command can be used to switch between branches. When you don't provide it with a hash value, Git assumes that you want to switch to a branch. Go on and switch to the new branch we just created and check the status just to be sure.
再次檢查狀態(tài)。 嗯,我們?nèi)栽趍aster分支上。 我們?nèi)绾吻袚Q到新分支? 還記得我們以前的朋友, git checkout嗎? 此命令可用于在分支之間切換。 當(dāng)您不為其提供哈希值時,Git會假定您要切換到分支。 繼續(xù)并切換到我們剛剛創(chuàng)建的新分支,并檢查狀態(tài)以確保。
$ git checkout signin_featureGo ahead and make a new file, file4 in this case and commit it. After you have successfully committed it, check the log. Certainly, you see the entry of the new commit sitting there.
繼續(xù)創(chuàng)建一個新文件,在這種情況下為file4并提交。 成功提交后,請檢查日志。 當(dāng)然,您會看到坐在那里的新提交的條目。
Let's switch back to master and view the log again. Uh-oh. The commit is missing. Did we erase it? Don't worry the commit is still there. Git is smart enough to know that this commit was in the signin_feature branch and the master branch has nothing to do with it yet.
讓我們切換回master并再次查看日志。 哦哦 提交丟失。 我們刪除了嗎? 不用擔(dān)心提交仍然存在。 Git非常聰明,知道此提交位于signin_feature分支中,而master分支與此無關(guān)。
Keep in mind that whenever you branch out, the new branch is a copy of the current branch you are on. As of now, we branched out from the master, hence all master commits were available in the log.
請記住,每當(dāng)分支出去時,新分支就是您所在的當(dāng)前分支的副本。 到目前為止,我們已經(jīng)從主服務(wù)器分支出來,因此所有主服務(wù)器提交在日志中都可用。
There is another way you can create a new branch. Our friend, git checkout helps us bypass the branch command entirely. Go on and type the following at your command line. Let's create a new subscription feature:
還有另一種創(chuàng)建新分支的方法。 我們的朋友git checkout幫助我們完全繞過了分支命令。 繼續(xù),在命令行中鍵入以下內(nèi)容。 讓我們創(chuàng)建一個新的訂閱功能:
$ git checkout -b subs_featureThe -b option lets you create a branch and switch to it all in one single command.
使用-b選項 ,您可以創(chuàng)建一個分支并在一個命令中將其全部切換到該分支。
Now that we've created some branches let's learn more about managing them. We have a total of 3 branches right now, but larger projects have hundreds or even thousands of branches. How do we keep track on which branches exist?
現(xiàn)在我們已經(jīng)創(chuàng)建了一些分支,讓我們進一步了解如何管理它們。 現(xiàn)在我們總共有3個分支,但是較大的項目有數(shù)百個甚至數(shù)千個分支。 我們?nèi)绾胃櫞嬖诘姆种?#xff1f;
Git lets us view all the branches in the repository by using the 'git branch' command:
Git讓我們使用'git branch'命令查看存儲庫中的所有分支:
$ git branchThis will give you a list of all branches along with your current branch. Let's say we decide to skip the subscription feature and delete it. Not every one of your ideas can get to the final project.
這將為您提供所有分支以及當(dāng)前分支的列表。 假設(shè)我們決定跳過訂閱功能并刪除它。 并非您的每個想法都可以進入最終項目。
You can use the -D option in the branch command to delete your branch:
您可以在branch命令中使用-D選項刪除您的分支:
$git branch -D subs_featureOops! We can't delete the branch we are currently working in. Switch back to master and try again.
糟糕! 我們無法刪除當(dāng)前正在使用的分支。切換回master,然后重試。
Phew! This was a long one. Good work. You deserve a cookie! Next up, we look into merging. What does that mean? Read on...
! 這是一個很長的時間。 辛苦了 你應(yīng)該得到一個餅干! 接下來,我們考慮合并。 那是什么意思? 繼續(xù)閱讀...
翻譯自: https://www.studytonight.com/github/branching-in-git
git 顏色擴展
總結(jié)
以上是生活随笔為你收集整理的git 颜色扩展_GIT:扩展的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: odoo第二天,请假单,权限第一天
- 下一篇: matlab中计算运行时间的函数,【谁能