[Git] GO over

复制代码
#Resetting the Stage:
git reset octofamily/octodog.txt


#Undo
#git reset did a great job of unstaging octodog.txt, but you'll notice that he's still #there. He's just not staged anymore. It would be great if we could go back to #how things were before octodog came around and ruined the party.
#Files can be changed back to how they were at the last commit by using the #command: git checkout -- <target>. Go ahead and get rid of all the changes #since the last commit for octocat.txt
git checkout -- octocat.txt


#Branching Out
#When developers are working on a feature or bug they'll often create a copy #(aka. branch) of their code they can make separate commits to. Then when #they're done they can merge this branch back into their main master branch.
#We want to remove all these pesky octocats, so let's create a branch called #clean_up, where we'll do all the work:
git branch clean_up


#Switching Branches
#Great! Now if you type git branch you'll see two local branches: a main #branch named master and your new branch named clean_up.
#You can switch branches using the git checkout <branch> command. Try it #now to switch to the clean_up branch:
git checkout clean_up


#Removing All The Things
#Ok, so you're in the clean_up branch. You can finally remove all those pesky #octocats by using the git rm command which will not only remove the actual #files from disk, but will also stage the removal of the files for us.
#You're going to want to use a wildcard again to get all the octocats in one #sweep, go ahead and run:
git rm '*.txt'


#Commiting Branch Changes
#Now that you've removed all the cats you'll need to commit your changes.
#Feel free to run git status to check the changes you're about to commit.
git commit -m "Remove all the cats"


#Switching Back to master
#Great, you're almost finished with the cat... er the bug fix, you just need to #switch back to the master branch so you can copy (or merge) your changes #from the clean_up branch back into the master branch.
#Go ahead and checkout the master branch:
git checkout master


#Preparing to Merge
#Alrighty, the moment has come when you have to merge your changes from #the clean_up branch into the master branch. Take a deep breath, it's not that #scary.
#We're already on the master branch, so we just need to tell Git to merge the #clean_up branch into it:
git merge clean_up


#Keeping Things Clean
#Congratulations! You just accomplished your first successful bugfix and #merge. All that's left to do is clean up after yourself. Since you're done with #the clean_up branch you don't need it anymore.
#You can use git branch -d <branch name> to delete a branch. Go ahead and #delete the clean_up branch now:
git branch -d clean_up


#The Final Push
#Here we are, at the last step. I'm proud that you've made it this far, and it's #been great learning Git with you. All that's left for you to do now is to push #everything you've been working on to your remote repository, and you're #done!
 git push
复制代码

 

posted @   Zhentiw  阅读(200)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
点击右上角即可分享
微信分享提示