At the time to fix bugs in a project, it is common to make a new branch to solve the issue but it can happen that it’s necessary to make more branches on the same “fix-branch” so it’s needed to mixed the branches into the base one with the commits included.
For that, the rebase command is used, firstly making rebase form the “changes branch” and after from the “base branch”. This command it is quite dangerous because it alternates the history of the “base branch” and it deletes the history of the branch merged.
In conclusion, this command is helpful if it is known well what it must be done, also it is considered a bad practice rebasing into the master branch and to the remote repository.
The power of this command resides in the option that it gives to save temporally changes that have not been committed and added. Once we use the command “git stash” we go back to the last commit, and the changes keep save temporally.
It’s possible to move to other branches meanwhile, but when it’s wanted to exit that stash state with the command “git stash pop” it has to be in the branch that was initiated or the changes will be lost.
Besides it’s possible to save those changes in other branches with the command “git stash branch nameUrBranch” after the git bash command.
Finally, if its wanted to delete the changes saved in the “git stash list” then it’s as simple as writing the following command: “git stash drop”.
In Conclusion the command “git stash” it’s used mainly to make small changes or ones that are not deserved to make a new branch or when it’s necessary to check other commits in other branches.
Cleaning no wished files.
There is this command “git clean” that will delete the files that git detect as not depend on the project like for example copies from the same files.
But to this command needs previously the following “git clean –run-dry” and Git will tell you which files it is going to delete. Finally, it is right the decision made, the command “git clean -f” will delete those files.
There are some files that will not be deleted like those in a folder and those ignored by Git. In this case it must be deleted manually.
This great command allows to bring old commits even from other branches. It’s only needed the ID of the commit it’s wanted to bring. This will come as a new commit, but it won’t be deleted so there will be two same commits.
This is a bad practice due it changes the history of the project and that it can be dangerous because it can make more chaotic the develop of the repository.