Git 的正确使用方法?
我有一个 bin/ 文件夹,其中包含大量 Bash、Python 脚本和一些 C 代码。
在这个文件夹中,我做了:
git init
git add file_name
我认为 git add . 不会很好,因为它会认为所有不同的脚本和程序都是同一个提交的一部分。 git status
命令只是滚动离开页面。当我创建一个分支时,我不知道该给它起什么名字。
为每个单独的项目创建一个文件夹来存放代码是否更好?然后在每个文件夹中运行这个?
git init
git add .
我认为这样分支也会更容易。这有用/推荐吗?什么是最佳实践
I have a bin/ folder with tons of Bash, Python scripts and some C code.
In this folder, I did:
git init
git add file_name
I thought git add .
would not be good because it would think that all the different scripts and programs were part of the same commit. The git status
command just scrolls off the page. When I create a branch I don't know what name to give it.
Is it better to make a folder for each individual project for code? Then run this in each folder?
git init
git add .
I think it would be easier to branch that way too. Is this useful/recommended? What are best practices
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,我强烈建议对每个目录/项目使用 git。
当您使用 github 并在机器上移动时,这也将非常有帮助,因为您将能够管理每个项目的代码并执行“git status”之类的操作来查看该项目的更改。
想象一下想要在一台新机器上使用一个单独项目的内容。如果您在一个存储库中拥有所有内容,则必须获取所有内容,然后选择您想要的内容。可能有一些聪明的方法可以解决这个问题,但我总是寻找最明智的 KISS 解决方案。
我不会按照你描述的方式使用 git 。为此,我会考虑更简单的 Dropbox 或其他基本云服务器存储风格的解决方案。 Dropbox 具有安全性,但如果您需要更个性化的安全解决方案,您会考虑更多私人托管等。
因此,您的问题的答案是:
“为每个单独的代码项目创建一个文件夹是否更好?然后在每个文件夹?
这有用/推荐吗?”
是是!
Yes I would strongly recommend using git for each directory / project.
This will also be very helpful when you use github and move around machines as you'll be able to manage the code for each project and do things like 'git status' just to see changes for that project.
Imagine wanting to use the contents of one individual project on a new machine. If you have everything in one repository, you'll have to get it all then select what you want. There's probably smart ways around that but I always look for the most sensible KISS solution.
I wouldn't use git the way you describe. For that I would consider a more simple Dropbox or other basic cloud server storage style solution. Dropbox has security but if you need a more personalized secure solution you'll looking at more private hosting, etc.
So the answer to your question of:
"Is it better to make a folder for each individual project for code? Then run this in each folder?
Is this useful/recommended?"
Is Yes!
这完全取决于您想要如何跟踪这些脚本的更改。您可以 git add 。 && git commit -s -m "initial commit" 一次性添加批次,然后跟踪对该组的未来修改。或者,您可以创建子目录来将子集作为单独的存储库进行管理,并使用软链接从 bin 文件夹链接到实际使用的版本。只有你才能真正决定。
It depends entirely on how you want to track changes to these scripts. You can
git add . && git commit -s -m "initial commit"
to add the lot in one go and then track future modifications to the set. Or you could create subdirectories to manage sub-sets as individual repositories and use soft-links to link from the bin folder to the actual version in use. Only you can decide really.我不确定我是否理解你的问题。如果您不想一次提交所有文件,并且您使用的是 Linux,则可以将 regexp 与 add 命令一起使用。然后提交它们。
我认为提交网格文件通常只发生在初始阶段。大多数时候您只修改或创建几个文件。因为您可以使用 git 签入任何单件更改,而无需花费太多成本。
I am not sure if I understand your question. If you don't want to commit all the files at one time, you can use regexp with your add command if you are using linux. Then commit them.
I think commit mesh files usually happen only at the initial stage. Most time you only modify or create several files. Because you check in any single piece changes with git without much cost.