git error: failed to push some refs to remote

(Note: starting Oct. 2020, any new repository is created with the default branch main, not master. And you can rename existing repository default branch from master to main.The rest of this 2014 answer has been updated to use “main“) (The following assumes github.com itself is not down, as eri0o points out in the comments: see www.githubstatus.com to be sure) If the GitHub repo has seen new commits pushed to it, while … Read more

How can I switch to another branch in git?

If another_branch already exists locally and you are not on this branch, then git checkout another_branch switches to the branch. If another_branch does not exist but origin/another_branch does, then git checkout another_branch is equivalent to git checkout -b another_branch origin/another_branch; git branch -u origin/another_branch. That’s to create another_branch from origin/another_branch and set origin/another_branch as the … Read more