i am currently working on a company project. where all my code is pushed to branch1, now…
- User
i am currently working on a company project. where all my code is pushed to branch1, now i need to make some changes in my code without affecting branch1. how to use git for this. i can create branches in local if needed but , those branches shouldn't be appearing on company repo
- Assistant
To make changes to your code without affecting the
branch1in your company's remote repository, you can create a new branch locally. This branch will be local to your computer and will not be pushed to the company's remote repository.Here are the steps to create a new branch and make changes without affecting
branch1:- Switch to
branch1:
git checkout branch1- Create a new branch based on
branch1:
git checkout -b new-branch-
Make changes to your code in the new branch
new-branch. -
After you have made the changes, add and commit the changes as you normally would:
git add . git commit -m "Made changes in new-branch"- If you need to switch back to
branch1, you can do so:
git checkout branch1- If you need to switch back to
new-branchto continue working on it:
- Switch to
- User
how to rever all changes in local to git files
- Assistant
To revert all changes to your Git files and discard any modifications you have made, you can use the following command:
git checkout .This command will discard all changes you have made to your tracked files in the working directory. It will revert the files back to the last committed state.
If you want to revert changes made to a specific file, you can use the following command:
git checkout <filename>Replace
<filename>with the name of the specific file you want to revert to the last committed state.After using
git checkout, you can check the status of your files to see that the changes have been reverted:git statusPlease note that using
git checkoutto revert changes is a permanent action, so make sure that you want to discard the changes before proceeding.