我有一个项目与git,我只是想克隆或拉一个特定的目录,像myproject/javascript就像subversion一样。 做一些改变,提交并再次提交。 这是可能的吗?
当前回答
经过试验和测试,这是可行的!
mkdir <directory name> ; //Same directory name as the one you want to pull
cd <directory name>;
git remote add origin <GIT_URL>;
git checkout -b '<branch name>';
git config core.sparsecheckout true;
echo <directory name>/ >> .git/info/sparse-checkout;
git pull origin <pull branch name>
希望这对你有帮助!
其他回答
有时,您只是想查看一下以前的文件副本,而不需要进行繁琐的差异处理。
在这种情况下,克隆存储库并签出感兴趣的特定提交并查看克隆存储库中的子目录也很容易。因为一切都是本地的,你可以删除这个克隆当你完成。
如果你想在不进入目录的情况下获得目录的最新更改,你可以这样做:
$ git -C <Path to directory> pull
也许这个命令会有帮助:
git archive --remote=MyRemoteGitRepo --format=tar BranchName_or_commit path/to/your/dir/or/file > files.tar
“就是这样”
在空目录中:
git init
git remote add [REMOTE_NAME] [GIT_URL]
git fetch REMOTE_NAME
git checkout REMOTE_NAME/BRANCH -- path/to/directory
经过试验和测试,这是可行的!
mkdir <directory name> ; //Same directory name as the one you want to pull
cd <directory name>;
git remote add origin <GIT_URL>;
git checkout -b '<branch name>';
git config core.sparsecheckout true;
echo <directory name>/ >> .git/info/sparse-checkout;
git pull origin <pull branch name>
希望这对你有帮助!
推荐文章
- 为什么我需要显式地推一个新分支?
- 如何撤消最后的git添加?
- Rubymine:如何让Git忽略Rubymine创建的.idea文件
- Gitignore二进制文件,没有扩展名
- Git隐藏错误:Git隐藏弹出并最终与合并冲突
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- 如何复制在bash所有目录和文件递归?
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 在Bash命令提示符上添加git分支
- 如何更改Git日志日期格式