- Create and switch to a new branch
git switch -c path_config
# Switched to a new branch 'path_config'
- How do I reset master to origin/master?
If -B is given, <new_branch> is created if it doesn’t exist; otherwise, it is reset
git checkout -B master origin/master
- Rollback a Git merge
With git reflog check which commit is one prior the merge
git reflog
git reset --hard commit_sha
- Delete a local branch
Switch to another branch and delete test_dev_branch
git checkout master
git branch -d <branch>
If the branch test_dev_branch is not fully merged you will get an error but you can force delete it using -D instead of -d
git branch -D <branch>
Delete test_dev_branch from remote
git push origin --delete <branch>
- Pull from master into the development branch
git checkout test_dev_branch # gets you on test_dev_branch
git fetch origin # gets you up to date with origin
git merge origin/master
- Switch to another branch
git checkout <branch>
- Create a new branch
git branch <branch>
- Git squash
Last three commits
git rebase -i HEAD~3
change the file
pick 12345 Commit 1
squash 54321 Commit 2
squash 98765 Commit 3
save and quit
fix the commit message
push
git push origin DEV-244 -f
- Empty directorie
https://git.wiki.kernel.org/index.php/GitFaq#Can_I_add_empty_directories.3F
- Remove .gitignore files from github
git rm -rf --cached .
git commit -m "rm files"
git push
git rm -r --cached .