by wmcc · 16y ago · 0 comments
$ cat git-create-branch #!/bin/sh
if [ $# -ne 1 ]; then echo 1>&2 Usage: $0 branch_name exit 127 fi
branch_name="$1" git push origin origin:refs/heads/${branch_name} git fetch origin git checkout --track -b ${branch_name} origin/${branch_name} git pull
First of all,
git push origin origin:refs/heads/${branch_name}
is totally unnecessary when creating a new branch.I see that there are remote branches you want to track. It's simple, no need for a script. Just make sure you are synced with the current version of the repo you are using (using `git pull`). Then:
git checkout --track -b bugfix origin/bugfix
Easy as pie. I even have an alias set when I want to do this, so I just call git cot bugfix origin/bugfix
To create a new branch locally (that doesn't track a remote), just call git checkout -b new-feature
Note: When using `git pull`, `git fetch` doesn't need to be called. Pulling changes will fetch them for you automatically.Everyone comes to the plate with different experiences/expectations. You can't hope to satisfy everyone.
hg branch new-feature
If you want it to branch from a different changeset than the one you're on, then: hg update deadbeef
hg branch new-feature
No flags, no orgin/newfeature (what does that even mean?), just the commands describing exactly what you're doing.