git : Cloned a remote repo, checked out a branch, committed a change…how to update branch on remote?

0

Issue

This is what the remote looks like.

--C0--------------C4--  (master) 
      \
       --C1-C2-C3--     (lite_main)

Actions I took:

  1. cloned the remote repo
  2. checked out lite_main
  3. made some changes and committed them

Results from git reflog:

27f07f4 HEAD@{0}: commit: ADDING ICON FILES TO FILE SYSTEM
445ef4b HEAD@{1}: checkout: moving from master to lite_main
f9cccc0 HEAD@{2}: clone: from git@bitbucket.org:username/somerepo.git

Results of git branch -a to try to show the tracked branches:

* lite_main
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/lite_main
  remotes/origin/master

(I don’t really know how to read this buy I’m guessing the only traced branch is my local origin/master is tracked to the remotes/origin/HEAD…is that right?)

Now my local repo looks like this:

--C0--------------C4--  (master) 
      \
       --C1-C2-C3-C5--     (lite_main)

How do I make my remote look like what I have locally? Will pushing lite_main to origin do it?

Solution

All you have to do is:

git push origin lite_main

Additionally, if you want to track the remote when creating the branch you can run the command (when creating the branch) git checkout --track -b <local branch> <remote>/<tracked branch>

Example git checkout --track -b foo remote/foo

Answered By – manojlds

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More