How to list all uncommitted changes made only in the current branch in git

I am new to git, initially I only worked on the main branch and then read a little about git branching, and I was amazed at its power, so I started using branches in my workflow

when I started with branching, my main branch was clean so as not to commit anything. Then I created a new feature1 branch

git checkout -b feature1 

i made my changes in the feature1 branch, added some js and css files. Then I created another branch from the master branch without making changes to the feature1 branch as follows:

 git checkout master git checkout -b feature2 

I added another code to the feature2 branch and added some new css files, and then again created another feature3 branch from the wizard with commit changes in the feature2 branch as follows:

 git checkout master git checkout -b feature 3 

I added new code to the feature3 branch with 1 new css file. now that i have done:

 git status 

I have a list of all the files that I changed but did not commit in all three branches. I expected that I would only get a list of files changed in the current branch ie feature3 , now I do not remember which files I created in which branch.

Can someone please help me list only the files that I created or changed in a particular branch and commit them. to the corresponding branches.

For instance,

list all files modified or created in the Feature1 branch, and transfer them to the feature1 branch and do it with all three branches.

I also want to know how I can create a branch from the master branch without getting other files that were changed in another branch but were not committed. i.e. I want the new branch to be an exact clone of the commit writer.

+6
source share
3 answers

As @abeaumet already mentioned, if you create files but don't execute them, you cannot track them when changing branches.

This is because they are in the working tree and not in the git repository. Your working tree is a truly proven version of your repository, as well as any changes you are currently making. Navigating through branches does not delete these unsolicited files; git leaves them in the working tree so that they are not deleted.

Read some articles related to this question to understand the difference between your repository and the working tree.

+5
source

Just run gitk --all and you can check all your branches, changes, whatever. Select a point and right-click on another, and on top - on two options.

A branch in git is just a โ€œlabelโ€ in the commit. If you create a branch on top of the wizard, it becomes as perfect a โ€œcloneโ€ as you can get. Although in reality it is just a 41-byte file containing the same hash.

I think you need to make friends a little with what is, from the description I could not deduce what you did, and especially what you need.

+8
source

It is not possible to determine on which branch the file was created if you did not commit it.

+5
source

Source: https://habr.com/ru/post/948137/


All Articles