Basic Git commands [part 3]

Hello again,

This is the third part of the serie “how to use basic commands of Git” (part 1 and part 2). Just to remember that this intend to be only a quick guide for who are working on Git. 🙂

Creating a new local branch from master branch (i.e., new branch name: code-v0.1):

$ git branch code-v0.1

Switch to the new branch and send it to remote repository:

$ git checkout -b code-v0.1
$ git push origin -u code-v0.1

Copying an existing branch to a new branch (i.e., new branch name is source_code-v0.1 that is gonna be created when copying) and send the copied branch to the remote repository:

$ git branch source_code-v0.1 code-v0.1
$ git checkout -b source_code-v0.1
$ git push origin -u source_code-v0.1

Deleting an existing branch from local and remote repository (WARNING: Keep in mind that if you delete an existing branch at remote repository, you’re not gonna be able to bring it back. So, make sure that you really wanna delete the branch.):

$ git branch -d code-v0.1
$ git push --delete code-v0.1 NOTE: delete from remote 

Renaming an existing repository and remove the old name (i.e., new name is my_code-r1). To remove, follow the steps immediately above.

$ git branch -m source_code-v0.1 mycode-stable 

So, that’s it,
Hope it was helpful, ’till next post.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s