Search code examples
gitgithubgitlabgit-pushgit-pull

How to create local for remote branch and push changes to remote using GIT


I have a master branch. I created a local-feature-branch from master and pushed changes to remote-feature-branch.

After pushing this, someone my local-feature-branch was lost. Now, how do i re-use the latest changes from the remote-feature-branch and create the same local-feautre-branch. Before re-using the latest changes from remote-feature-branch, i need to get latest from master and push it to -remote-feature-branch

Once created, if i make any changes to the local-feature-branch, how do i push this to remote-feature-branch.

This is a little confusing. can someone please help


Solution

  • I am not sure if I understand Your problem correctly, but my understanding is that You want to use the remote feature branch and merge it with master.

    Let's name the feature branch feature-branch for the purpose of simplicity. I assume here that Your remote repository is named origin.

    What You can do is:

    git checkout origin/feature-branch
    git rebase master
    git push origin feature-branch --force
    

    Alternatively, instead of rebase You can use merge to merge the master to Your branch.