I use EGit in eclipse to pull and push.
my config is:
[remote "origin"]
fetch = refs/heads/*:refs/remotes/origin/*
push = refs/heads/*:refs/remotes/origin/*
local branch is master
Remote Tracking branch is origin/master
when I do push, it comes out "origin/master:master[up to date]". Actually the remote branch is not up to date. I wander if I configure the wrong way.
Sometimes I change different configure, I will get either "create a new branch"(which is wrong, as I just push some commits) or "reject-no fast forward"(which is strange, as I am the only user of the remote repository and I have already fetch before push)
Check with Egit if you aren't in a detached HEAD mode:
If HEAD is "detached", i.e. is not pointing to the tip of a local branch but to a commit or tag, then none or several "checked-out" markers may appear in the tree, since any number of remote branch or tags may point to the currently checked out commit.
The state you are in while your HEAD is detached is not recorded by any branch (which is natural --- you are not on any branch).
(See "Why did git detach my head?" for probable cause, and "Git: How can I reconcile detached HEAD with master/origin?" for reconciliation).
That is a common cause for an "up to date" message when pushing to a remote repo.
After I push to upstream successfully, like version 0.3.9, I continue to change my codes locally and submit a version 0.5.0. This submit should based on version 0.3.9. I don't know why. That's why I have to do merge every time, and sometimes merge make my codes messy.
Related
I have a fork of microsoft/vscode-arduino on github. Some time ago I submitted a PR that was accepted. Time passed and now I want to do some more work.
At the time my use of git and github weren't very sophisticated and I rather foolishly did all the work on master.
On my local repo I pulled from upstream master, merged and committed to my fork, and was surprised to find that github thinks my fork is still 7 commits ahead and 113 behind.
Then I tried to rebase on the upstream as described on this page My pull request has been merged, what to do next? but the command
git pull --rebase origin master
and after a bit of mucking about I'm no commits behind and 12 commits ahead.
I really don't care about preserving anything. Everything important has long since been merged into the upstream repo. I just want to make this main exactly the same as current main in the upstream, so I can branch for my new efforts fixing an ongoing problem where every time there's a release of VS Code that uses a different version of node it breaks the serial port native integration until the Arduino extension is updated to the same release of Node and released.
Can anyone advise on how to do that? (discard the 12 commits ahead, not the N-API thing)
This may not be the most elegant but it worked.
Use GitLens in VS Code to find the oldest commit that isn't mine and do a hard reset to that.
In the terminal pane, git push --force. Refreshing the github page it now says I'm two commits behind origin (the repo I forked). I'm rid of the unwanted commits. Now to work forward.
In VS Code terminal pane git pull --rebase upstream master
In VS Code click on the status bar to sync.
Refresh the github web page. Hooray, This branch is even with microsoft:master.
I was committing and pushing in ordinary for my repository.
but once i used command of git checkout for change to the previous version of my repository.
after that i tried to commit and push, then it can not completed.
i try to use the --no-verify command to push the commit but it also not success.
error: failed to push some refs to 'https://github.com/ruwanliyanage123/Hair-4-U-Hospital.git'
i want to push my commit into github repository
Since you switched to a previous version of your repository, your head is most probably detached. You can't just go back anywhere in your history and make commits.
Consider making a branch from there and then commit to it.
Try to first check in which branch you are working do git branch, check is the one you are working. Then I sometimes do git pull to just make sure that the connection is working this should not delete your progress the you should be able to do git push. If you are afraid youll mess up first do a local back up of all project files except for the .git one which are hidden by default in windows.Lastly I would suggest never posting the actual link to your github repository in case whatever you are working is important, you can just replace with
https://github.com/user/projectname.git
I recently created a project on Eclipse. I set up a git repository on the project. Pushed the code to a new repository on GitLab.
I checked out (Import->Project from Git) the project to another laptop, made updates, committed it as another author and pushed it back to repository (2nd commit /revision). I only removed the target runtimes from the project as the changes.
I went to my 1st laptop and wanted to try update / pull my code. I right-clicked on the repository from the Git Repository view -> Remote -> Fetch. I entered the path to the repository and etc and fetched the repository. But, my project still has the old code having the target runtime. I know I only 'fetched' the repository, not 'pulled' maybe.
So I was confused, the code was not updated. If I am not mistaken, I right-clicked the repository again, clicked on 'Check Out'. This was the result :
After 'Checkin Out', the target runtimes on my project were removed, updated like from the 2nd commit. But there are now 2 branches and 2 refs. I don't what state my local repository is in now. And/but the local master branch was still in 'initial commit', isn't it confusing?.. My code has been updated..
I only read a bit of the git manual online, and I haven't yet be able to wrap my head around concepts like refs.
I could just delete the project and Import->Project from Git, right?
But if I can I would like to know what happened to my project (local repository) and how to fix this?
Thx
I'm not familiar with egit and its menus. But I try to answer your question with git commands which you can run in the console. And I think you can figure out which egit menu items are corresponding to these commands.
You wanted to pull and update the local master in the first laptop repository. You needed git checkout master first, which could be skipped if you were already on master and then git pull origin master. However you did git fetch origin master instead, which just updated origin/master with the new commit. It would have been okay to use git fetch origin master if git merge FETCH_HEAD or git merge origin/master followed imediately, because in many cases pull = fetch + merge, but you didn't.
I guess you then did git checkout origin/master. Checking out origin/master leads to detached HEAD state. To make it easier, you could just consider the detached HEAD as a nameless branch. When you make new commits, this namelss branch will grow. But you can't see these commits on other branches unless you apply these commits to them. Git has some commands to apply commits, including git merge, git rebase, git cherrypick, etc.
To fix the current situation, you can simply run git checkout master;git pull origin master.
So to make my answer more simply. Commit changes on your deateached head and make branch with this commit and then merge it together and push to master.
You can just download again your project if you didn't make changes on detached head that you need.
Is set up a Project from Git in ZendStudio 9. (basing on eclipse with eGit)
It generates a quiet normal fetch refspec:
Remote Fetch Specification +refs/heads/*:refs/remotes/original/*
But a very mysique push refspec:
Remote Push Specification HEAD:refs/for/refs/heads/master
In the remote i can see by "git ls-remote" the following:
8db575549dea67a45cea04358f902993c940c4d8 HEAD
16f0939153e6ef12b4596f0d4fb43fa5b8b0246b refs/for/refs/heads/master
8db575549dea67a45cea04358f902993c940c4d8 refs/heads/master
And i have on local machine the message by "git status":
On branch master
Your branch is ahead of 'original/master' by 5 commits.
So, please pay Attention, because my Question is not "What does it means"...
My Question is:
What does this workflow means? What is the Sense?
What is this generated Ref on the Server "refs/for.." for?
Isn't it better to work on a local branch instead of having a ref on the server to push?
Thanks in advance.
One, a usual Gerrit related refspec should be (as commented by jszakmeister in "Gerrit Code Review - Uploading Changes")
HEAD:refs/for/branchname
So, if anything, it should have been
HEAD:refs/for/master
But in your case, you don't need that kind of refspec (since you don't have Gerrit)
Is this a usual way to commit,
No, it is not.
is it a bad default, worth nothing?
In your case, yes, it isn't useful.
This could be a side effect of what this thread mentions:
Indeed, Gerrit is integrated and shipped together with EGit feature. Currently there is no way to disable Gerrit from within Zend Studio.
The bug 347077 "Make Gerrit features Optional" is still open.
the OP tweini comments:
To go out of this trap, iI had to realize, that this ref is creating a branch on remote without a remote tracking branch associated with it.
But to get rid of it is pretty easy:
Change push refspec in .git/config to push = refs/heads/master:refs/heads/master,
Push your local repo to remote git push
Delete the branch on remote git push --delete origin refs/for/refs/heads/master
When I create a new branch from a remote branch using EGit I get the wrong remote tracking set up:
I create the local branch feature1 from the remote branch refs/heads/master and immediately push to upstream. The followign remote tracking gets configured in my .git/config file:
[branch "feature1"]
remote = origin
merge = refs/heads/master
So, pull and push in that branch will pull and pull from/to the remote master branch. I would expect the following tracking configuration instead:
[branch "feature1"]
remote = origin
merge = refs/heads/feature1
I know I can fix it even from EGit, but I'm worried about other developers in my team not realizing this and pushing uncompleted features to the master branch.
Am I doing something wrong?
Egit will, by default, take the upstream branch for the merge parameter when creating a branch from a remote one.
That means, if you want to enforce the policy which is to push to remote/master only from a local branch master, you can try and enforce it locally.
Check if Egit respects a git config push.default current for pushing only the current branch to an upstream branch with the same name (which might actually become the default policy after git1.7.10).
However, that has the issue of making sure every developer has that policy active in his/her repo.
(I don't think you can enforce it at the "central" repo one, where you could add a server-side hook like an update hook: that script take the name of the branch being updated (ie here 'master', not the name of the branch in the downstream repo, ie here 'feature1')
Note: bug 378960 has been marked as resolved (February 2014) in Egit 3.2:
Push Branch / Initial Push wizard simplifies pushing a branch and also allows upstream configuration for new branches created by the push operation:
Maybe you should advise developers to create feature-branches not from the remote-tracking branch (e.g. origin/master), but from the local one (master). This way, EGit will not set up any remote tracking by default.
If you then decide to publish the branch for the first time, it should be possible to set up the remote tracking (the equivalent of git push --set-upstream) after bug 378960 is implemented.