In Git 1.7.0 and later, you can checkout a new branch:
git checkout -b <branch>
Edit files, add and commit. Then push with the -u
(short for --set-upstream
) option:
git push -u origin <branch>
Git will set up the tracking information during the push.
Related Posts:
- How do I push a new local branch to a remote Git repository and track it too?
- How do I push a new local branch to a remote Git repository and track it too?
- How do I delete a Git branch locally and remotely?
- How do I delete a Git branch locally and remotely?
- What does ‘–set-upstream’ do?
- What does ‘–set-upstream’ do?
- error: src refspec master does not match any
- What is the difference between git push origin and git push origin master
- How do I rename both a Git local and remote branch name?
- How do I push a local Git branch to master branch in the remote?
- How do I rename a local Git branch?
- What is the best (and safest) way to merge a Git branch into master?
- How do I properly force a Git push?
- How to remove local (untracked) files from the current Git working tree
- Git merge hotfix branch into feature branch
- GitHub: Permission denied (publickey). fatal: Could not read from remote repository
- Git fetch remote branch
- How do I clone a specific Git branch? [duplicate]
- Git fetch remote branch
- How do you push a tag to a remote repository using Git?
- How to change the URI (URL) for a remote Git repository?
- How to get just one file from another branch?
- Update Git branches from master
- Create a branch in Git from another branch
- Create Git branch with current changes
- How to get the current branch name in Git?
- How do you create a remote Git branch?
- Move the most recent commit(s) to a new branch with Git
- Move the most recent commit(s) to a new branch with Git
- Make an existing Git branch track a remote branch?
- How do I call git diff on the same file between 2 different local branches?
- How to get the current branch name in Git?
- How do you create a remote Git branch?
- Meaning of the GitHub message: push declined due to email privacy restrictions
- Download a single folder or directory from a GitHub repo
- Branch from a previous commit using Git
- Clone A Private Repository (Github)
- How do I rename a repository on GitHub?
- How to remove remote origin from a Git repository
- Not a valid object name: ‘master’
- ! [rejected] master -> master (fetch first)
- How do I copy a version of a single file from one Git branch to another?
- Git: Merge a Remote branch locally
- Undoing a ‘git push’
- Move existing, uncommitted work to a new branch in Git
- What are the differences between “git commit” and “git push”?
- What does git push origin HEAD mean?
- What does git push origin HEAD mean?
- Delete branches in Bitbucket
- Git’s local repository and remote repository — confusing concepts
- Repository size limits for GitHub.com
- How do you clone a Git repository into a specific folder?
- How to keep a branch synchronized/updated with master?
- Can I arrange repositories into folders on Github?
- Git removing upstream from local repository
- How do you merge two Git repositories?
- How do I run git log to see changes only for a specific branch?
- How to create a local branch from an existing remote branch?
- How do I clone a subdirectory only of a Git repository?
- How to find which git branch I am on when my disk is mounted on other server
- Git push hangs when pushing to Github?
- How to create a new branch from a tag?
- Git push requires username and password
- Could not find wp-load.php issue
- What does cherry-picking a commit with Git mean?
- How do I undo the most recent local commits in Git?
- Undo a Git merge that hasn’t been pushed yet
- fatal: Not a git repository (or any of the parent directories): .git [duplicate]
- Git pushing to remote branch
- How do I undo ‘git add’ before commit?
- How can I see the differences between two branches?
- How do I resolve git saying “Commit your changes or stash them before you can merge”?
- How to cherry-pick multiple commits
- Another git process seems to be running in this repository
- rejected master -> master (non-fast-forward)
- Can I share my private GitHub repository by link?
- How to rename a directory/folder on GitHub website?
- Create a git patch from the uncommitted changes in the current working directory
- git push says “everything up-to-date” even though I have local changes
- git: fatal: Could not read from remote repository
- Why does git say “Pull is not possible because you have unmerged files”?
- How to see the changes between two commits without commits in-between?
- My new Github page isn’t showing up
- Update Git branches from master
- Why should I use core.autocrlf=true in Git?
- How can I add a blank directory to a Git repository?
- Git Extensions: Win32 error 487: Couldn’t reserve space for cygwin’s heap, Win32 error 0
- Is it possible to pull just one file in Git?
- Completely cancel a rebase
- How to discard local changes and pull latest from GitHub repository
- Git: What’s the best practice to “git clone” into an existing folder?
- Git merge reports “Already up-to-date” though there is a difference
- git-diff to ignore ^M
- Differences between Commit, Commit and Push, Commit and Sync
- How to modify a specified commit?
- How can I push a specific commit to a remote, and not previous commits?
- Git ignore local file changes
- Import existing source code to GitHub
- git checkout all the files
- Git beginner: Keeping track of on-server changes