简体   繁体   中英

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:

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.

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. In this case, git commit would still include changes made to any of these files.

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” "path_to_files/*"

I would make sure to keep the git add as well just in case you added any new files.

More details on git commit options can be found here:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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