我是git的新手,希望能够正确使用它。
git init
git add . // added the whole directory
git commit -m "initial stage"
git checkout -b "version1"
git branch
master
* version1
现在我想在目录中添加一些新文件
cp /path/to/file/admin.php /path/to/git/folder/.
这些文件应仅包括在version1分支中,但它们也被包括在主分支中。
git add admin.php
git status
On branch version1
Untracked files:
(use "git add <file>..." to include in what will be committed)
admin.php
git checkout master
git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
admin.php
问题是如何仅在特定分支上添加文件?谢谢。
git add
和git commit
,否则它将继续不存在于存储库中的任何位置,仅存在于您的工作目录中。您需要从一些git基础知识开始...(技术上讲,git add
会将其保存到临时文件中,但在git commit
步骤之前不会变为永久性)。 - torek