I am working with three forked versions of a source code. FYI I changed the names to not disclose identities/repos. Here is how it is laid out:
MyMBP:~/Documents/_library$ git remote -v
abc https://github.com/abc/_library (fetch)
abc https://github.com/abc/_library (push)
origin https://github.com/123/_library.git (fetch)
origin https://github.com/123/_library.git (push)
upstream https://github.com/source/_library (fetch)
upstream https://github.com/source/_library (push)
Here, upstream is the original source code that is the most up to date and stable version. Origin is my forked version. ABC is someone else's version.
ABC had a branch that I pulled from to work off of. I wanted to then make changes and push up to my repo (origin), and subsequently submit a pull request. The branch on ABC, was called "abc/obs-noise".
Upon git status:
git status
HEAD detached from abc/obs-noise
When I made the changes to said file, I committed:
git commit
[detached HEAD e8eeea3] OBSERVATION NOISE ADDITION TO THE MONITORS
1 file changed, 23 insertions(+), 11 deletions(-)
Then I git pushed (supposedly to my origin).
git push -u origin abc/obs-noise
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 733 bytes | 733.00 KiB/s, done.
Total 5 (delta 4), reused 1 (delta 0)
remote: Resolving deltas: 100% (4/4), completed with 4 local objects.
To https://github.com/123/_library.git
* [new branch] abc/obs-noise -> abc/obs-noise
However, I go to my repo... no abc/obs-noise, or any evidence of this commit. I am a noob at git, but I am almost sure I did everything right and it looks that way. I am wondering where do I find my commit? I would hate to redo all my work.
First of all, you are sitting on a detached HEAD. It means that any commit that you have just made will not move the original branch pointer. So you have great chances to lose these commits if you change active branches, and that's why git push doesn't push anything new: original branch pointer hasn't been moved.
First of all, when you start working on any of remote branch you should create a local branch, corresponding to a given remote branch. Use
git checkout -b <local_branch_name> <remote>/<branch>
Then as you make commits, this <local_branch_name> will advance to follow your commits line. When you need to push a given commit line to a remote branch, use
git push <remote> <local_branch_name>:<remote_branch_name>
If you need to have several development lines for different remotes, you should created several corresponding local branches and push them separately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With