-Having a main branch called “main” and a working branch called “myproject” we want to restore the branch “myproject” to the branch “main“
-Set to the root folder of your git projects, type
git reset –hard main
Tested on: Git 2.36
-Having a main branch called “main” and a working branch called “myproject” we want to restore the branch “myproject” to the branch “main“
-Set to the root folder of your git projects, type
git reset –hard main
Tested on: Git 2.36
-Having a git repository with URL “https://github.com/user/ProjectA” with a branch called “development“
-Set to the root folder of your git projects, type
git clean -fdx
Tested on: Git 2.36
-Having a git repository with URL “https://github.com/user/ProjectA” with a branch called “development“
-Set to the root folder of your git projects, type
git clone –branch main https://github.com/user/ProjectA
Tested on: Git 2.36
-Having a main branch called “main” and a working branch called “myproject” we want to restore on branch “myproject” the file “filename.ext” with the version on branch “main“
-We switch to the “myproject” branch
git checkout myproject
-We use the restore command
git restore –source main — filename.ext
-Now we must stage and commit the change of the file “filename.ext” on branch “myproject“
Tested on: Git 2.36
-Having a main branch called “main” and a working branch called “myproject” where all changes are committed
-We switch to the “main” branch
git checkout main
-We bring all the changes from the “main” branch
git fetch
git pull
-We return to the branch “myproject“
git checkout –
-We start the interactive rebase from “main” branch to “myproject” branch
git rebase -i main
—-Here we resolve conflicts (if they exist), squash committees, etc…
-We push the rebase changes to the “myproject” branch
git push –force-with-lease
Tested on: Git 2.36