Git- some how a single branch having two names created how do i make it single - git-branch

I just tried to rename the branch with following command
git branch -m <oldname> <newname>
my older branch name is feature/AAM-443 and this branch is already merged with parent now when i renamed it with feature/AAMN-443 and push it to remote then the branch in network is showing
*<commit id> feature/AAM-443, feature/AAMN-443
and if i do some commit to feature/AAMN-443 then graph is like
* <new-commit id> feature/AAMN-443
|
|
* <old-commit id> feature/AAM-443
what is happening i am wondering that what the meaning of a branch having two names is it some symbolic reference and why the feature/AAM-443 is still there why not it removed can anyone help

To add to #RomainValeri's answer, a branch can't have two names, so what you did was this:
You had a remote tracking branch:
git branch -a
feature/AAM-443
origin/feature/AAM-443 <-- tracked by feature/AAM-443
You renamed your branch locally:
git branch -m feature/AAM-443 feature/AAMN-443
git branch -a
feature/AAMN-443
origin/feature/AAM-443 <-- still thinks it's tracked by feature/AAM-443
You pushed your renamed branch to origin:
git push -u feature/AAMN-443
git branch -a
feature/AAMN-443
origin/feature/AAMN-443 <-- tracked by feature/AAMN-443
origin/feature/AAM-443 <-- no longer tracked by any local branch!
Then you made a new commit and pushed:
git commit -am "new commit" <-- on branch feature/AAMN-443
Your remote repo updated like this:
o <-- origin/feature/AAMN-443
|
o <-- origin/feature/AAM-443 (branch is no longer tracked! It has been left behind!!)
Like #RomainValeri said, you need to delete origin/feature/AAM-443:
git push --delete origin feature/AAM-443

You just have to remove the remote counterpart that's still there.
(assuming your remote is named origin here)
git push --delete origin feature/AAM-443
# or
git push origin :feature/AAM-443

Related

Why cant I upload any new project to GitHub?

I have been going at the endlessly all semester. I was able to add project from my prior year in school but have been unable to push and new projects to my repository.
I have tried deleting my key credentials via my key access chain.
I have created a new GitHub account and tried using that one.
I have deleted repositories started from scratch over and over.
I have read question on question and tried following multiple different answers on here.
What I wouldn't give to understand what is going on and why nothing seems to allow me to push a project anymore.
The most current attempt was going back to my original GitHub account.
I created a brand new repository.
I created a new folder and copied my simple python project into it and saved.
error: remote origin already exists.
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 pythonGame % git remote rm origin
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 pythonGame % git remote rm upstream
error: No such remote: 'upstream'
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 pythonGame % git remote add origin https://github.com/stephanieBrandon/GuessARandomNumberGame.git
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 pythonGame % git push -u origin main
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/stephanieBrandon/GuessARandomNumberGame.git'
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 pythonGame % ls -a
. .. guess_a_random_number.py
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 pythonGame % git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /Users/stephaniebrandon/Documents/GitHubPortfolio/Python/GuessARandomNumberGame/pythonGame/.git/
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 pythonGame % git remote add origin https://github.com/stephanieBrandon/GuessARandomNumberGame.git
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 pythonGame % git push -u origin main
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/stephanieBrandon/GuessARandomNumberGame.git'
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 pythonGame % ls -a
. .. .git guess_a_random_number.py
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 pythonGame % git status
On branch master
I am hoping there is just some simple thing I am missing, if someone could explain and help me out it would be much appreciated.
Stephanie, your local branch name is "master", not "main" as you can see from the "git status" output.
If you try "git push origin master", it should work.
You dont have branch main, you have branch master. 😊
Try:
git push origin master
You need to have some commits before pushing your repository to Github.
Moreover, your local default branch name is master, so you have to use git push -u origin master instead of git push -u origin main
$ ls
guess_a_random_number.py
$ git init
Initialized empty Git repository in /Users/stephaniebrandon/Documents/GitHubPortfolio/Python/GuessARandomNumberGame/pythonGame/.git/
$ git add .
$ git commit -m "initial commit"
$ git remote add origin https://github.com/stephanieBrandon/GuessARandomNumberGame.git
$ git push -u origin master # not main

Error failed to push some refs to git commit

I'm trying to upload a navbar file to git, but it keeps saying that some references couldn't be pushed, and I don't know where I'm going wrong.
PS E:\navbar> git init
Initialized empty Git repository in E:/navbar/.git/
PS E:\navbar> git add README.md
fatal: pathspec 'README.md' did not match any files
PS E:\navbar> git commit -m "first commit"
Author identity unknown
*** Please tell me who you are.
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got '신은영#DESKTOP-0T69V65.(no
PS E:\navbar> git remote add origin https://github.com/kimdohyeon0811/learnit
PS E:\navbar> git push -u origin main
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/kimdohyeon0811/learnit'
PS E:\navbar> git remote -v
origin https://github.com/kimdohyeon0811/learn_css.git (fetch)
origin https://github.com/kimdohyeon0811/learn_css.git (push)
PS E:\navbar> git push origin master
error: src refspec master does not match any
error: failed to push some refs to 'https://github.com/kimdohyeon0811/learn_css.git'
PS E:\navbar>
You have two separate problems here, and they're related. The first is that you've failed to configure your the name and email used in your commits, and so Git is refusing to commit any changes. The second is that because you have no commits in your repository, trying to push the branch main or master doesn't work, because it doesn't exist. That's the message that you're getting when you see “src refspec
does not match any.”
You need to configure your name and email, which are stored in user.name and user.email. Note that user.name is a personal name, not a username. So, for example, someone might run these commands:
$ git config --global user.name "Pat Doe"
$ git config --global user.email pdoe#example.com
Then, once you've made those changes, you can commit and it should succeed. Once you have commits, you can push them.
Note that if you want to use main as the default branch but your repository is using master, you can run git branch -m main and that will rename the branch. If you want to do that, do it before you push.

Create a 'release' entry in Github

I'd like to create a release entry on my Github project.
I tried this from the cli
git commit -a -m 123
git tag -a "123" -m "msg"
git push
This commits the files but I don't see a release tab entry - nor do I see the tag.
Thanks.
By default, the git push command doesn’t transfer tags to remote servers. You will have to explicitly push tags to a shared server after you have created them.
From Git Basics - Tagging
No need for the double quotes on git tag - git tag -a 123 -m "msg"
Use the --tags flag on push - git push --tags

Cannot push onto github

I want to pysh my project to a github repository called luna.git:
I followed the instructions
echo “# luna” >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/raouiyounes/luna.git
git push -u origin master
But I get this error
error: src refspec master does not match any.
error: impossible de pousser des rĂ©fĂ©rences vers ‘https://github.com/raouiyounes/luna.git’
Maybe you just need to commit.
Try this:
git add .
git commit -m "initial commit"
git push origin master
You can do :
git push origin HEAD:branch-name

How to Commit in github?

i am getting error sh.exe: notepad: command not found please short out my problem
Thanks
For the commit to GitHub part, you need to add (if you have created an empty yourRepo on GitHub):
git config user.name yourGitHubUsername
git config user.email yourGitHubEmail
git add .
git commit -m "First commit"
git remote add origin https://yourAccount#github.com/yourAccount/yourRepo
git push -u origin master
If that fails because GitHub already created one commit when you initialized your "empty" repo (it can add by default a README.md and a .gitignore), do a:
git pull --rebase origin master
git push -u origin master
If you really have to call notepad from a mingw session, you can use this wrapper:
#!/bin/sh
'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar \
-nosession -noPlugin "$(cygpath -w "$*")"
But remember you can use msysgit from a DOS session as well.
Seps:
1.git init
2. git status
3. git add .
4. git commit -a
5. git status