Git Branch commands

ls -la .git/refs/heads (for viewing references)
git log --one line (to see the commit)
Git creating branch....

Source:Lynda 

$ git branch new_feature
$ git branch
* master
  new_feature

  • To check where the head is now(where new commit)

$ cat .git/head


  • To swtich the branch

$git checkout new_feature



  • To copy a specific branch 

$git clone -b branch_name https://link

  • To create and switch branch at a time
$git checkout -b  title_branch (it will create and switch to title_branch)

If you didn't commit the working directory after making changes and want to swtich the branch it will gives you warning "Please, commit your changes or stash them before you can switch branches. Aborting" or in other word the working directory must be clean

On this you can take three different steps
.Commit the changes
.do switch and lose the changings
.

To push the branch
git push --set-upstream origin challange_10


0 comments:

Post a Comment

My Instagram