[Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (2024)

110 962

solution 1

Mais quand j'essaie de pousser pour maîtriser j'obtiens

fatal : Vous n'êtes pas actuellement sur une branche. Pour pousser l'historique menant à la branche actuelle (TETE détachée)

Ce qui est à prévoir

Travailler dans un état détaché estpasà prévoir, à moins que vous ne vouliez délibérément le faire, ce dont je doute que ce soit le cas pour vous. Au lieu de vérifier le commit #5, vous devriez soit avoir annulé lemaîtrebrancher à ce commit, ou faire ungit rebaseen mode interactif où vous pouvez ressasser les commits comme vous le souhaitez.

Ceci dit, si vous êtes certain que la version demaîtredans l'état détaché est ce que vousvraimentvoulez garder, alors vous pouvez contourner lepas d'avance rapideerreur, en poussant de force la branche vers la télécommande :

git push origin HEAD:master --force

Cependant, si vous forcez le push, vous courez le risque de causer des problèmes à tous les autres utilisateurs qui ont extrait cette branche. Une solution moins risquée serait de créer une branche temporaire à partir du HEAD détaché, puis de fusionner cette branche dansmaître:

git branch temp-branchgit checkout mastergit merge temp-branchgit push origin master

solution 2

avez-vous assuré que vous avez vraiment dans une branche? utiliserbranche gitet vérifiez si vous êtes dans une succursale. sinon, justegit checkout branche-nom-que-vous-voulezet puisgit pousserc'est bien!

solution 3

git pousservous permettra uniquement d'avancer rapidement la télécommande. Cela signifie que le commit que vous essayez de pousser doit être un descendant de la branche distante. Puisque vous avez modifié les commits précédents après 5, vous n'avez pas de descendant mais plutôt un cousin. Tu peux donnergit push --forcesi vous souhaitez écraser la branche, mais si d'autres personnes ont apporté leurs propres modifications au-dessus du maître actuel, elles ne pourront plus extraire la branche. De plus, si quelqu'un d'autre pousse à maîtriser avant vous, ses modifications seront perdues. Généralement, vous ne voulez pas forcer le push si vous n'êtes pas le seul à utiliser une branche.

solution 4

Si vous poussez vers un nouveau référentiel, vous pouvez utiliser

git push origin HEAD:refs/heads/main --force

principalvoici une nouvelle branche qui sera créée au cas où votre référentiel cible serait vide.

solution 5

Vous pouvez créer une nouvelle branche et vous pouvez fusionner ces changements dans la branche précédente

git checkout -b newBranch git checkout previousBranchgit merge newBranchgit push origin previousBranchgit branch -d previousBranch

Voir plus de solutions

Partager:

110 962

Vidéos similaires sur Youtube

[Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (1)

02 : 33

COMMENT RÉPARER : erreur : impossible de pousser certaines références vers | Créer un référentiel GitHub distant en 2 minutes

Brandon Colchin

123271

[Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (2)

01 : 25

la branche maître actuelle n'a pas de || en amont git || Résolu à 100 %

Talent numérique

185

[Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (3)

03 : 59

Erreur Git | Erreur GitHub : échec du transfert de certaines références vers '[URL REPO]'

Le codeur solo

84

[Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (4)

02 : 56

Le maître de branche actuel n'a pas de branche en amont dans git

Sagar S

30

[Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (5)

09 : 58

38. Que signifie git push -u ? Définir en amont pour la branche locale à l'aide de l'option -u dans la commande push - GIT

Leela Développeur Web

5

[Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (6)

02 : 25

Comment réparer les erreurs GitHub Push Rejected + Explication

LearnToCode - Darija marocaine

3

[Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (7)

04 : 13

Correction rapide de l'erreur "fatale : la branche actuelle n'a pas de branche en amont" de Git

Cameron McKenzie

2

[Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (8)

02 : 12

Empêcher git push directement vers la branche master par n'importe quel contributeur

Poursuite

1

[Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (9)

Auteur par

Tom Hammond

Mis à jour le 13 août 2021

commentaires

  • [Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (10)

    Tom Hammond presque 2 ans

    Le maître est-il au niveau du commit #10. Cependant, j'ai fini par réaliser que j'avais cassé quelque chose en cours de route qui n'avait pas été détecté par les tests.

    J'ai fini par aller au commit #5, puis j'ai lentement refait le développement de chaque commit et l'ai ajusté continuellement pour m'assurer qu'il ne cause pas à nouveau le bogue. Maintenant, je suis essentiellement de retour au commit #10, mais avec un certain nombre de modifications qui empêchent le bogue de se produire.

    Je veux maintenant créer le commit #11 en utilisant mes modifications. Mais quand j'essaie de pousser pour maîtriser j'obtiens

    fatal : vous n'êtes pas actuellement sur une branche. Pour pousser l'historique menant à l'état actuel (tête détachée) maintenant, utilisez git push master HEAD :

    Ce qui est à prévoir. Mais comment puis-je réellement faire en sorte que cela soit transmis à ma succursale distante ?

    J'ai essayégit push origin HEAD:maîtremais ensuite obtenu ceci:

    ! [rejected] HEAD -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/tomhammond/sample.git'hint: Les mises à jour ont été rejetées car une pointe de branche poussée est derrière sa indice distant : contrepartie. Consultez cette branche et intégrez la modification distante : (par exemple, 'git pull ...') avant de pousser à nouveau.

    Quand je fais unstatut gitJe voisTÊTE détachée du 4a74ac3

    • [Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (11)

      scrrower presque 8 ans

      Vous êtes-vous assuré que votre historique de commit jusqu'au #10 est ce qu'il était à l'origine, et que seul votre commit #11 contient les modifications ? Une erreur comme celle-ci est normalement donnée lorsque votre branche et la branche d'origine ont un historique de validation différent (comme ce qui se passe lorsque vous refaites le développement de chacun des commits)

    • [Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (12)

      Tom Hammond presque 8 ans

      Je suis sûr qu'ils ne le font pas. Je pense que j'ai bêtement commencé à faire le développement après avoir vérifié #5

    • [Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (13)

      scrrower presque 8 ans

      C'est bien, ce que vous pouvez faire, c'estgit reset [commit10Hash]pour annuler la mise en scène de vos modifications, puisgit cachettepour les garder un peu,git reset --hard origin/nameofremotebranchpour le remettre à l'origine,git cachette poppour réappliquer les modifications souhaitées, puisgit add .etgit commit -m "Vos nouvelles modifications au-dessus de l'origine". Vous devriez alors pouvoirgit push nom d'origine de la branche distantesans conflit

  • [Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (14)

    Tom Hammond presque 8 ans

    Excellente information - je suis en fait le seul à travailler dessus en ce moment, donc je pense que cela devrait fonctionner

  • [Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (15)

    scrrower presque 8 ans

    Forcer la poussée vers une branche principale ne peut certainement jamais être une bonne idée

  • [Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (16)

    Tim Biegeisen presque 8 ans

    @scrowler J'ai ajouté un flux de travail qu'il peut utiliser pour éviter la poussée forcée.

  • [Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (17)

    Gwyneth Llewelyn plus de 3 ans

    Bien qu'il s'agisse d'une réponse très simple, c'est généralement ce qui résout la plupart des problèmes menant à la question du PO. Dans mon cas, j'étais revenu à un commit antérieur, j'avais corrigé quelques problèmes et fait quelques poussées - mais j'avais oublié que le HEAD était toujours détaché ! Votre solution a tout réglé pour moi. Merci 🙏

  • [Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (18)

    Giorgi Tsiklauri plus de 3 ans

    @RobbieAverill pourquoi?

  • [Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (19)

    scrrower plus de 3 ans

    @GiorgiTsiklauri pour de nombreuses raisons, dont l'une est que si vous travaillez en équipe avec un flux de travail en ramification, vous désynchroniserez tout le monde

  • [Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (20)

    oulukbek sur 1 an

    tu m'as sauvé la vie frère. merci

Récent

Pourquoi le fichier PNG avec Drop Shadow dans Flutter Web App est-il granuleux ?

Comment dépanner les plantages détectés par Google Play Store pour l'application Flutter

Le sélecteur Cupertino DateTime interfère avec le comportement de défilement

Pourquoi awk -F fonctionne-t-il pour la plupart des lettres, mais pas pour la lettre "t" ?

Flutter change la couleur de mise au point et la couleur de l'icône mais ne fonctionne pas

Comment imprimer et se connecter à l'imprimante à l'aide de Flutter Desktop via USB ?

Des problèmes critiques ont été signalés avec les versions suivantes du SDK : com.google.android.gms:play-services-safetynet:17.0.0

Flutter Dart - obtenir le nom du pays localisé à partir du code du pays

navigatorState est null lors de l'utilisation de pushNamed Navigation onGenerateRoutes de GetMaterialPage

Gestionnaire de Sdk Android introuvable - Erreur Flutter Doctor

Flutter Laravel Push Notification sans utiliser de tiers comme (firebase, onesignal..etc)

Comment changer la couleur de ElevatedButton lors de la saisie de texte dans TextField

En rapport

[Résolu] Git push master fatal : Vous n'êtes pas actuellement sur une branche (2024)

FAQs

How to fix the current branch master has no upstream branch? ›

How to fix Git error: The current branch has no upstream branch.
  1. # attempt to push while the current branch # does not track any upstream branch $ git push fatal: The current branch master has no upstream branch. ...
  2. $ git push --set-upstream origin master ... ...
  3. $ git push Enumerating objects: 5, done.

How do I push code to master main in git? ›

  1. To push the main repo, you first have to add the remote server to Git by running git remote add <url> . ...
  2. To finally push the repo, run git push -u origin <branch-name> ...
  3. That's how you push the main branch for the first time. ...
  4. To confirm that the branch has been pushed, head over to GitHub and click the branches drop-down.
Sep 9, 2022

How to push files from master to main branch in git? ›

There are five main steps:
  1. Copy the master branch and history to main.
  2. Push main to the remote repository, i.e. GitHub / GitLab.
  3. Point HEAD to the main branch.
  4. Change the default branch to main on the remote.
  5. Delete the master branch on the remote repo.
Oct 19, 2021

How to push local master branch to remote git? ›

  1. In this tutorial, you will learn how to push a branch to a remote repository in Git.
  2. Step 1: Check if Git is tracking all the necessary files.
  3. Step 2: Commit any changes to the local branch.
  4. Step 3: Fetch the changes from the remote repository.
  5. Step 4: Add the remote server.
  6. Step 5: Switch to the master branch.
Mar 30, 2023

How do I reset my master branch to remote master? ›

How to reset a Git branch to a remote repository
  1. Save the state of your current branch in another branch, named my-backup ,in case something goes wrong: git commit -a -m "Backup." git branch my-backup.
  2. Fetch the remote branch and set your branch to match it: git fetch origin. git reset --hard origin/master.

How do I reset my branch master? ›

To reset the develop branch into the master branch, first, go to the Git repository and check the list of all local branches. Then, switch to the “develop” branch, run the “git merge –no-commit master” command to merge, commit and override the added changes.

How do I merge local branch to master? ›

Steps to merging branch into master
  1. Git fetching. The initial command to run is git fetch for getting the latest updates of your repository. ...
  2. Git rebasing. Then, you need to git rebase (suppose, the name of remote is origin, which is by default). ...
  3. Switching to master. ...
  4. Pulling changes. ...
  5. Merging changes. ...
  6. Pushing changes.

How do I pull a master code into my branch? ›

To pull the master into the branch in Git, first, move to the Git local repository and fetch all data and references of the remote repository into the local repository. Then, pull the master into the remote branch using the “$ git pull origin master” command.

How do I change my branch from master to main? ›

1 Answer
  1. rename your local branch: git branch -m master main.
  2. change the tracked branch git fetch -p origin git branch -u origin/main main.
  3. change the main local branch git remote set-head origin -a.
  4. optionally, remove the master branch, local and remotely: git branch -D master git push origin :master.
Apr 21, 2022

How do I push code to Github repository from command line? ›

Open TerminalTerminalGit Bash. Change the current working directory to your local project. In the Command prompt, add the URL for the remote repository where your local repository will be pushed. Push the changes in your local repository to GitHub.com.

How do I move files from master branch to another branch? ›

Solution 1: Use the git checkout command
  1. Checkout to the branch where you want to copy the file. git checkout feature/A.
  2. Once you are on the correct branch, copy the file. git checkout feature/B -- utils.js.
  3. Use the git status command to ensure that the file has been copied.
  4. Commit and push to a remote.
Jun 6, 2022

How to push single file in git? ›

How to Push a File or Folder to Github (using Git Bash)
  1. Move your file to the cloned repository.
  2. Open Git Bash.
  3. Go to the current directory where you want the cloned directory to be added. ...
  4. Add the file and stage it for commit. ...
  5. Commit the file to your local repository. ...
  6. Push the changes to Github.
Sep 22, 2022

How do I push from one remote branch to another? ›

In order to push your branch to another remote branch, use the “git push” command and specify the remote name, the name of your local branch as the name of the remote branch.

How do I push a local commit to a remote branch? ›

To push the commit from the local repo to your remote repositories, run git push -u remote-name branch-name where remote-name is the nickname the local repo uses for the remote repositories and branch-name is the name of the branch to push to the repository.

How do I push a remote branch to a remote? ›

Push a new Git branch to a remote repo
  1. Clone the remote Git repo locally.
  2. Create a new branch with the branch, switch or checkout commands.
  3. Perform a git push with the –set-upstream option to set the remote repo for the new branch.
  4. Continue to perform Git commits locally on the new branch.
Oct 3, 2021

What does it mean when current branch has no upstream branch? ›

Stand out in System Design Interviews and get hired in 2023 with this popular free course. The fatal: The current branch master has no upstream branch error occurs when you have not configured git in such a way that it creates a new branch on the remote.

What does the current branch master has no upstream branch mean? ›

If you see the message “the current branch has no upstream” in your command window, it means you've tried to git push to a remote repository from a local branch that has not yet been connected to a remote branch.

What does it mean if the current branch has no upstream branch? ›

When you are working on a new branch, the remote repository doesn't know about your branch until you push that branch to it. This is why you get the error: The current branch master has no upstream branch. if you try to run git push on a branch that isn't in your remote repository yet.

How to set upstream branch for current branch? ›

Set Upstream Branch Using Git Push

Now, we can set the upstream branch using the git push command along with the -u flag or option. The overall command for the same is: We have another command that can be used as an alternative to the git push -u origin command. We can use the --set-upstream command for the same.

Top Articles
Latest Posts
Article information

Author: Rubie Ullrich

Last Updated:

Views: 5849

Rating: 4.1 / 5 (72 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Rubie Ullrich

Birthday: 1998-02-02

Address: 743 Stoltenberg Center, Genovevaville, NJ 59925-3119

Phone: +2202978377583

Job: Administration Engineer

Hobby: Surfing, Sailing, Listening to music, Web surfing, Kitesurfing, Geocaching, Backpacking

Introduction: My name is Rubie Ullrich, I am a enthusiastic, perfect, tender, vivacious, talented, famous, delightful person who loves writing and wants to share my knowledge and understanding with you.