0

在添加实际内容之前,我正在使用 git 进行一些示例测试。

这是我所做的:

enter code here
1) Create an empty git repository

$ mkdir git_trial2
$ cd git_trial2
$ git init (Creates a .git directory inside this)
$ cg-branch-add branch1 (Create a branch1 inside this git)
$ touch File1
$ echo "This is a test" >> File1

现在我想将 File1 添加到 branch1。这该怎么做?

4

2 回答 2

1

你可以

git checkout branch1
git add File1
git commit -am "added File1"
git checkout other_branch

和 File1 只会在 branch1

于 2011-06-30T11:04:45.040 回答
1

好吧,我们真的需要知道你的神秘cg-branch-add命令做了什么,但假设它只是添加了一个分支,git branch那么你需要先切换到该分支:

git checkout branch1

然后添加文件:

git add File1

并提交:

git commit
于 2011-06-30T11:04:46.690 回答