
Restore a revision in a new branch git checkout -b 4.

For example, you can restore or rebase a revision in a new branch. The next time you change anything to that file, that file will reflect in the Git status. This command will revert your branch to a specific commit, but will keep your changes on your local machine. All commits that come after this version are effectively undone your project is exactly as it was at that point in time. This command will revert your branch to the specific commit. This command has two different options ––hard and ––soft. By default, it will rewind to the last commit, but you can pass on a commit hash with the command to revert it to a specific commit. Reset Your BranchĪnother one of the advanced Git features can be used to reset your branch, to revert or to rewind to the last commit. This command is useful whenever you need an independent branch without any relation to any other available branches. It can be accomplished by using the Git checkout command with the ––orphan option. So the first commit in this branch will be the root of this branch without having any history. An orphan branch is a separate branch that starts with a different root commit. If you want to share your branch with someone else with no history, you can do that by creating an orphan branch.


This command is useful to fetch the required branch quickly to fix the issues in a big project. You need to mention the name of the branch, such as staging or development and the path of the Gitlab or Github repo. To fetch a specific branch’s content, you need to trigger the same Git clone command along with the name of the branch you want to clone. Cloning a Specific BranchĪs mentioned in the previous previous blog, an existing repo can be cloned using the Git clone command, but what if you need to clone only a specific branch of the repo? For example, if you have master, staging and development branches, you may just want to clone the staging branch.
#Switch into branch from master git code
Often we ask questions like: What are the differences in our code files and branches? How do we download a piece of code? How can we merge changes to remote? This blog will help you answer these questions and provide you a brief summary of some advanced Git features. These six #GitCommands make web development easier. In general, we mostly use the basic Git commands in projects, like Git clone, Git pull, Git checkout, Git add and Git commit, although in some cases we need advanced Git features to check our work. This is one of the most important parts of our daily work. Please show your love and support by sharing this post.At Rubico, we use Git to manage our source code. Force-delete the temporary branch from local git repository.Merge changes from the temporary branch into the destination branch.Navigate/checkout to the "destination branch" where we need the changes.Save a new commit object in the local git repository.

