VisualStudio code & compile_commands.json

If you are working with C/C++ in VSCode, you will find that VSCode keeps on showing

"${workspaceFolder}/build/compile_commands.json" could not be found. 'includePath' from c_cpp_properties.json will be used instead.

This message is generated by vscode-cpptools. Although it is an optional file however vscode-cpptools keeps on showing error message that it is missing.

This message can easily be fixed if you are using CMake. To do so simply add following to your CMake configuration file.

# Generate compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

rename git branches

Let’s rename a git branch locally & remotely.

Let’s assume that you got git repository with multiple branches and you want to mark a branch as a master whereas existing master to something else.

  • Make note of the branch names and their respective remote
git branch -vv
  • Goto server repo and switch default branch
git symbolic-ref HEAD refs/heads/new-master
  • Goto local repo, checkout master
git checkout master
  • Rename it locally
git branch -mv master something
  • Remove remote branch
git push origin --delete master
  • Set new remote
git branch --unset-upstream
git push --set-upstream origin something
  • Goto server repo and switch default branch
git symbolic-ref HEAD refs/heads/something
  • Switch to branch which is going to be new master
git checkout new-master
  • Rename this branch
git branch -mv new-master master
  • Remove remote branch
git push origin --delete new-master
  • Set new remote
git branch --unset-upstream
git push --set-upstream origin master
  • Goto server repo and switch default branch to master
git symbolic-ref HEAD refs/heads/master