Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Wednesday, 23 August 2017

Rename local git branch

Problem:

How do I rename a local git branch using git command line?

Solution:

If you'd like to rename the currently checked-out branch to "new_branch_name":

git branch -m new_branch_name

If you'd like to rename any branch ("old_branch_name") to "new_branch_name":

git branch -m old_branch_name new_branch_name

References:

Thursday, 20 July 2017

Make local Git branch track a remote branch

Problem:

How do I get a local git branch to track a remote branch?

Solution:

The following examples assume a branch "thebranch" and a remote "myremote". They also assume you are using git in the command line.

For Git 1.8.0 and later:

If you've already checked out "thebranch" on your local, then:

git branch -u myremote/thebranch

If you haven't checked out "thebranch" on your local, then:

git branch -u myremote/thebranch thebranch

For Git 1.7.0 until 1.7.12.4, if you've checked out "thebranch" on your local, then:

git branch --set-upstream-to=myremote/thebranch

If you haven't checked out "thebranch" on your local, then:

git branch --set-upstream-to=myremote/thebranch thebranch

References:

Wednesday, 14 March 2012

Ignore all .svn folders with .gitignore

If you find yourself looking to use both Subversion and Git together for any reason, in order to ignore all .svn folders in a project directory tree using your .gitignore file, add the following to your .gitignore file:

.svn

This assumes that no .svn directories or files inside of them have been committed yet. Also, note that there aren't any wildcard characters, (e.g. "*"). If you are using GitX, refresh your 'commit' view to see the changes after making this change to your .gitignore file.