Git for economists
  • Introduction
  • Git concept
  • Installing Git
  • Using Git for the first time
  • Using Remote Repository
  • Working with branches
  • Extra commands
  • Appendix - .gitignore file example
  • Page 1
Powered by GitBook
On this page

Was this helpful?

Working with branches

The full power of git comes with branches.

Under construction...

To switch to a branch, use

git switch my-brach

If the branch does not exist, simply add c (for create):

git switch -c my-branch

To switch back to the branch that was active before, use

git switch -

If some changes in files have not been saved, git might not accept to switch (the files would be overwritten), so you can simply stash the changes to be able to retrieve them later once you are back on the branch

git stash save "message to descript the stash"

Then to get the changes back do

git stash pop
PreviousUsing Remote RepositoryNextExtra commands

Last updated 6 months ago

Was this helpful?