简体   繁体   中英

Git rebase upstream/master - Please, commit your changes or stash them before you can switch branches

I'm working on a local copy of forked repo.

Before I push the changes I want to make sure that my copy is up to date with upstream/master. This is what I did:

$ git fetch upstream

$ git add /webroot/wp-content/plugins/cbp_recycling

$ git commit -m "cbp_recycling added"
[develop 36411f0] cbp-recycling added
42 files changed, 830 insertions(+)

$ git status
# On branch develop
# Your branch is ahead of 'origin/develop' by 1 commit.
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       logs/
#       webroot/.htaccess
#       webroot/wp-content/plugins/CBP_Promobox/
nothing added to commit but untracked files present (use "git add" to track)


$ git rebase upstream/master
First, rewinding head to replay your work on top of it...
error: Your local changes to the following files would be overwritten by checkout:
        webroot/wp-config.php
Please, commit your changes or stash them before you can switch branches.
Aborting
could not detach HEAD

wp-config.php did change as I've added my DB credentials, but then why is it not listed when I run git status?

My .gitignore file:

.idea
.vagrant
.DS_Store

What am I doing wrong and how to update my local copy to upstream/master.

git is telling you that you need to add also lists of the directories:

  logs/
  webroot/.htaccess
  webroot/wp-content/plugins/CBP_Promobox/

this depends of the root dir of your branch.

now you can todo this: goto the root dirand type:

  git add -p

or if you want add all

  git add .

to select wath you want add

after you type

  git commit 

and auto start nano for type your commit messages

now for pushing it

  git push

if is fisrt time push

  git push -u origin/develop

in any case you're working on the branch develop and why you rebase master?

to enter changes to develop a master, after commit and pushing,you must goto in branch master and type

  git pull
  git merge develop

hope this help you git merge

My mistake. I've checked the .git\\info\\exclude file and I found webroot/wp-config.php there. I also remember adding it there now.

However it didn't fix the problem. Git status still returns nothing, so I've ended up doing:

$ git checkout webroot/wp-config.php

$ git merge upstream/master

Manually update wp-config.php to make sure that everything works fine and pushed the changes to repo.

What is your way of working with git and config files?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM