vue git课程
介绍
这不是Java,而是几个新手开发人员提出了相同的问题,如何使用GIT以及GIT的工作原理,所以就这样了……
您曾经在SVN工作吗? 好吧,忘记一切,让我们重新开始
什么是GIT回购?
通常有两个镜像存储库。 您的本地存储库和远程存储库。 是的两个回购。 团队中的每个人都有整个回购的实际副本,因此即使远程服务器死了,您也可以再次设置它,然后将回购推入(破坏)回购服务器。
您的本地存储库由git维护的三棵“树”组成:
- 包含实际文件的工作目录。 的
- 作为分期的索引
- HEAD,指向您所做的最后一次提交。
因此,让我们开始速成课程...
创建一个新的git仓库。
#Start a git repository in the particular path git init
检出存储库
#Create a working copy of a local repository by running the command git clone /path/to/repository #When using a remote server, your command will be git clone [email protected git clone [email protected ]:/path/to/repository
添加并提交
#Shows current branch status and lists files that have changes. #First it lists files in the Stage (to be committed) #And below go the files that are not staged. git status #You can propose changes (add it to the Index) using git add #Or if you want to add everything git add . #Or even git add --all #To actually commit these changes use git commit -m "An awesome commit message :p" #If a file was added to the stage by mistake undo a stage git reset particularFile.extension #Reseting code by deleting all changes. HEAD is the latest local commit git reset --hard HEAD #Same as above but N commits back. git reset --hard HEAD~N #Reset code but keep changes locally. (usefull #Reset code but keep changes locally. (usefull for uncommiting a not pushed mistake) #Use HEAD~ 2 if a merge occured. git reset --soft HEAD~ 1 #Save local uncommitted changes temporarily git stash #Bring saved changes back git stash apply
检查出门时发生了什么事……
#Use to see changes committed. Commit it can be found by git log git show --pretty= "" --name-only [commitID] Pushing changes #Your changes are now in the HEAD of your local working copy. To send those changes to your remote repository in your desired branch, execute git push origin Branching
更新和合并
#You can study repository history using and get commit id if needed #You can study repository history using and get commit id git log
如何使用git bisect发现错误
这东西坏了! 上周工作了! 发生了什么? 我们能否指出破坏它的代码!
是的,我们过去都进行过对话...假设我们有良好提交消息 (这是另一个帖子主题,但继续进行),我们将使用git bisect。
您为git bisect提供了两个点,一个良好的时间点和一个不良的时间点。 假设这些是提交HEAD和134245634bkl2730bc5der。 它将时间一分为二,并在这之间给您提交。 如果代码正确,则将其标记为GOOD,否则将其标记为BAD。 经过一些迭代后,您将进入导致问题的提交。 查看下面的例子
git bisect start HEAD 134245634bkl2730bc5der Bisecting: 4 revisions left to test after this (roughly 2 steps) [3453lj45b3ljhrgo2ug42bbh98112] Revert "Refactored hello() method to pass sonar" #test your code here git bisect bad #or use a script that exits 1 git bisect bad #or use a script that exits Bisecting: 2 revisions left to test after this (roughly 1 step) [x7y435h34r87yhndfdsf0dsfw3452] Added some nice staff I found on the web git bisect good #or use a script that exits 0 git bisect good #or use a script that exits Bisecting: 0 revisions left to test after this (roughly 0 steps) [234fy435h45b09jdfdsf0dsfw3452] Added ability to fly like superman git bisect bad 234fy435h45b09jdfdsf0dsfw3452is the first bad commit commit 234fy435h45b09jdfdsf0dsfw3452 Author: Alexius [email protected Author: Alexius [email protected ] Date: Sat Oct 12 15 : 40 : 46 2019 Added ability to fly like superman bisect run success
那就是您需要的有关GIT的所有信息!
请享用!
翻译自: https://www.javacodegeeks.com/2019/10/git-essentials-crash-course.html
vue git课程