Home > other >  new git branch up to date but can't push new files and folders
new git branch up to date but can't push new files and folders

Time:04-11

I have created a new branch named "new_code". I have more files in the code and I want to push everything to this new branch.
After git push origin new_code I have the same files and folders in the new_code branch as I have in my main branch.
But I don't have the newer files, I want to have all the project folders and files in the new branch. Forcing a push didn't help either. git status On branch new_code nothing to commit, working tree clean
How can I update my branch, I don't mind deleting it and start new

CodePudding user response:

To create a new branch on the remote site you have to use

git push $REMOTE $LOCAL_BRANCH_NAME:$REMOTE_BRANCH_NAME

So in your case it'd be git push origin new_code:new_code

CodePudding user response:

workflow to use new branch:

git checkout master # starting point
git pull # make sure all is up to date
git checkout -b new_code # create new branch
touch f1 # make some changes
git add . # stage all the changes
git commit -m "changes in f1 are awesome" # commit change
git push -u origin new_code # push and track new branch

generally to see what is going on use:

git status

CodePudding user response:

You can get your actual branch with : git status, the name will be after On branch. Copy this name.

  • Add your files with git add .
  • Add a commit message with git commit -m "your changes message"
  • Then you can do : git push origin localBranchName:RemoteBranch -f

ex: If git status return On branch main To push on new_code branch you need to do: git push origin main:new_code

  •  Tags:  
  • git
  • Related