简体   繁体   English

推送不同分支 Github 中某些文件的更改

[英]Push changes for some files in different branch Github

I have cloned a repository with many directories.我克隆了一个包含许多目录的存储库。 I am making changes to multiple of these directories.我正在对这些目录中的多个进行更改。

I want to create a separate branch for each one of these directories and push my changes on each branch for the selected files only.我想为这些目录中的每一个创建一个单独的分支,并仅针对所选文件在每个分支上推送我的更改。 While being on master branch (confirmed with git status ) and at the exact directory that I want to commit&push, I tried:在 master 分支上(通过git status确认)和我想要提交和推送的确切目录中,我尝试了:

git add Files_for_branch01
git commit -m "files 01”
git checkout -b branch01 
git push -u origin branch01

but all changes were uploaded.但所有更改都已上传。 I mean I got on branch01 changes of Files_for_branch02.我的意思是我得到了 Files_for_branch02 的 branch01 更改。

I'm completely confused.我完全糊涂了。 Any ideas?有任何想法吗?

Command git add is used to add files that are not already being tracked, but in your case it sounds like the folders and their contents existed when you cloned.命令git add用于添加尚未被跟踪的文件,但在您的情况下,听起来文件夹及其内容在您克隆时已经存在。 In this case, git commit would still include changes made to any of these files.在这种情况下, git commit仍将包含对这些文件中的任何一个所做的更改。

If you only want the commit to include files from a certain path then add the path specification.如果您只希望提交包含来自某个路径的文件,则添加路径规范。 For example, replace git commit -m "files 01” with:例如,将git commit -m "files 01”替换为:

git commit -m "files 01” "path_to_files/*"

I would make sure to keep the git add as well just in case you added any new files.我会确保保留git add以防万一您添加了任何新文件。

More details on git commit options can be found here:可以在此处找到有关git commit选项的更多详细信息:

https://git-scm.com/docs/git-commit https://git-scm.com/docs/git-commit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM