Eclipse github How to change my Project message when i have pushed - eclipse

I first commit blog, the messages is ok.
When I push next time, the message is no change.
I check my history, these were be pushed
What is master & HEAD?
How to change my Project message when I have pushed?

To modify a commit message right-click the commit and choose Modify > Reword. Technically, changing the commit message means to replace the commit and all its subsequent commits with a new commit due the message and the references to the parent(s) are part of the commit (you can see this by the fact that the Id of the commit has changed).
If you have already pushed the replaced commenit, the rewritten Git history requires a force-push: right-click the HEAD commit and choose Push Commit.... In the Push Branch master dialog check the option Force overwrite branch in remote if it exist and has diverged. But beware, rewriting the remote Git history is problematic when you collaborate with others via your GitHub repository. Therefor GitHub allows to disable force pushing.
What is master & HEAD?
The commit where you are (in your local repository) is marked with HEAD. The latest/head commit of a branch is marked with the branch name: master is the name of the main/default branch (like trunk in SVN/Subversion).

Related

GitHub: Commit a point in history as the head of master

There is a certain commit I did to my Git repository which I host in GitHub. After that commit I've made several other commits, which were bad and redundant, in a second look. I thus need to revert to the certain commit / certain point in history before these bad changes.
I didn't find a button like "revert to this version" or "commit this version as the head of this branch (master)".
As you can see, I just want to make that older version the head of the master branch. How will you do that from GitHub?
Update
I emphasize: I ask on GitHub, not on git or any GUI other than GitHub.
If I understand you correctly you want a past commit as the last commit on the branch.
If so, using examples with origin and master:
Use git reset <comit_id> and then git push origin +master to push & delete all commits past the one you reset to. Notice the + sign before the branch name (master).
Note that this is irreversible (as far as I know) so take the necessary precautions.

Commit and Push keeps making new branch (Eclipse)

When using eclipse and I want to Commit / Push changes, using the Git Staging view I can hit commit, then on the Git repositories view push the branch to the remote branch. However when I hit Commit and Push it creates a new branch? The local branch is called master and the remove is origin/HEAD, and the new remote created is origin/master. The default branch is origin/HEAD. I've been Commit and Pushing to the default until today.
I've been searching for an answer for a while but I couldn't really find one, sorry if this is a duplicate.
It didn't [say that the current branch is NO-HEAD]. In the history it says it is HEAD "refs/heads/master" if that's helpful?
HEAD isn't a separate branch. It's just a pointer to the branch that is currently checked out.

Restore branch deleted from GitHub

I had a branch on a GitHub project that I merged into master. I then clicked the 'delete branch' button on GitHub, and thought I was all set.
Turns out I wasn't, and I want to restore/reactivate the branch. I did not delete the branch on my local respository, nor did I run any git fetch/pull afterward. Just clicked the delete button on GitHub.
Wanted to sound out what a good next step should be. Thinking of doing git push from my local box but wasn't sure what the repercussions might be, would the remote repo on GitHub squawk about a dead branch being brought back, etc.
If you didn't remove your branch from your local machine, and you got rights to push to GitHub, you can restore it on Github by pushing it again
git checkout localBranchName
git push origin localBranchName
It doesn't matter if you make a fetch from Github, git wont remove your local branch until you explicitly tell it to do so with
git branch -D localBranchName
In fact, even if you had removed your local branch, if you merged it previously with master, you can restore it locally. You have to go to the last commit, prior to the merge and branch from there. Something like this for example:
git checkout master
git checkout -b localBranchName
git reset --hard HEAD~1 ( 1 is the number of commits you want to undo )
The second command will create a new branch pointing to your last commit on master
The third command will the last commit undoing (only on that branch ) the merge with master.
Another thing you can do is use "git reflog". That command is very usefull since it will show each time you moved between branches and/or commits.
Go to your list of commits. Find the commit with the merge and click on the pull request number (the number prefixed with #). This will direct you to a page with info about the merge and a button with the label 'Restore branch'. Click that and it is restored.
It looks like there is a "Restore branch" button now that shows up in place of the "Delete branch"

Egit rejected non-fast-forward

I am getting this message while pushing to github repository. Can you tell me step by step procedure to fix it? I pushed only once and it was successful. But, when I updated a project and tried to push my second commit, it shows "master rejected non-fast-forward" and does not allow me to push. Please explain the procedure.
I had this same problem and I was able to fix it. afk5min was right, the problem is the branch that you pulled code from has since changed on the remote repository. Per the standard git practices(http://git-scm.com/book/en/Git-Basics-Working-with-Remotes), you need to (now) merge those changes at the remote repository into your local changes before you can commit. This makes sense, this forces you to take other's changes and merge them into your code, ensuring that your code continues to function with the other changes in place.
Anyway, on to the steps.
Configure the 'fetch' to fetch the branch you originally pulled from.
Fetch the remote branch.
Merge that remote branch onto your local branch.
Commit the (merge) change in your local repo.
Push the change to the remote repo.
In detail...
In eclipse, open the view 'Git Repositories'.
Ensure you see your local repository and can see the remote repository as a subfolder. In my version, it's called Remotes, and then I can see the remote project within that.
Look for the green arrow pointing to the left, this is the 'fetch' arrow. Right click and select 'Configure Fetch'.
You should see the URI, ensure that it points to the remote repository.
Look in the ref mappings section of the pop-up. Mine was empty. This will indicate which remote references you want to fetch. Click 'Add'.
Type in the branch name you need to fetch from the remote repository. Mine was 'master' (btw, a dropdown here would be great!!, for now, you have to type it). Continue through the pop-up, eventually clicking 'Finish'.
Click 'Save and Fetch'. This will fetch that remote reference.
Look in the 'Branches' folder of your local repository. You should now see that remote branch in the remote folder. Again, I see 'master'.
Right-Click on the local branch in the 'Local' folder of 'Branches', which is named 'master'. Select 'Merge', and then select the remote branch, which is named 'origin/master'.
Process through the merge.
Commit any changes to your local repository.
Push your changes to the remote repository.
Go have a tasty beverage, congratulating yourself. Take the rest of the day off.
In my case I chose the Force Update checkbox while pushing. It worked like a charm.
In the meantime (while you were updating your project), other commits have been made to the 'master' branch. Therefore, you must pull those changes first to be able to push your changes.
Applicable for Eclipse Luna + Eclipse Git 3.6.1
I,
cloned git repository
made some changes in source code
staged changes from Git Staging View
finally, commit and Push!
And I faced this issue with EGit and here is how I fixed it..
Yes, someone committed the changes before I commit my changes. So the changes are rejected.
After this error, the changes gets actually committed to local repository.
I did not want to just Pull the changes because I wanted to maintain linear history as pointed out in - In what cases could `git pull` be harmful?
So, I executed following steps
from Git Repository perspective, right click on the concerned Git
project
select Fetch from Upstream - it fetches remote updates (refs and objects) but no updates are made locally. for more info refer What is the difference between 'git pull' and 'git fetch'?
select Rebase... - this open a popup, click on Preserve merges during rebase see why
What exactly does git's "rebase --preserve-merges" do (and why?)
click on Rebase button
if there is/are a conflict(s), go to step 6 else step 11
a Rebase Result popup would appear, just click on OK
file comparator would open up, you need to modify left side file.
once you are done with merging changes correctly, goto Git Staging view
stage the changes. i.e. add to index
on the same view, click on Rebase-> Continue. repeat 7 to 10 until all conflicts are resolved.
from History view, select your commit row and select Push Commit
select Rebase Commits of local....... checkbox and click next. refer why - Git: rebase onto development branch from upstream
click on Finish
Note: if you have multiple local repository commits, you need to squash them in one commit to avoid multiple merges.
Configure
After pushing the code when you get a rejected message, click on configure and click Add spec as shown in this picture
Drop down and click on the ref/heads/yourbranchname and click on Add Spec again
Make sure you select the force update
Finally save and push the code to the repo
Open git view :
1- select your project and choose merge
2- Select remote tracking
3- click ok
Git will merge the remote branch with local repository
4- then push
This error means that remote repository has had other commits and has paced ahead of your local branch.
I try doing a git pull followed by a git push. If their are No conflicting changes, git pull gets the latest code to my local branch while keeping my changes intact.
Then a git push pushes my changes to the master branch.
In my case i forgot to pull the new changes from git
Right click on the project Fetch From Upstream
Right click on the project Pull
Right click on the project Push to Upstream
I have found that you must be on the latest commit of the git.
So these are the steps to take:
1) make sure you have not been working on the same files, otherwise you will run into a DITY_WORK_TREE error.
2) pull the latest changes.
3) commit your updates.
Hope this helps.
Go in Github an create a repo for your new code.
Use the new https or ssh url in Eclise when you are doing the push to upstream;

GitHub fork a repo from previous commit

I've found a repository on GitHub I would like to fork - but not the current version.
I want to fork the repo as it was quite a few commits back - is this possible? The repo has not marked any releases, so I'm not sure how to do this. I could obviously copy the code as it was in that commit, but I would prefer to fork, as then I get the link back to the original repo.
You can only fork the current repository.
You can reset the forked repository's master branch to an earlier commit though, making it look like as if you had forked it at that point.
See: How can I rollback a github repository to a specific commit?
If you reset every branch, it effectively resets your repository to an earlier state of the original repository (with exception of branch-independent data, like configuration, hooks etc which are not reset). Since it's possible that not all branches contain the commit from the master branch, you might need to look up commits by date for each branch, to reset them to the last commit before the commit from which you want to fork.
I was also unable to do this using github, but Sourcetree handled it perfectly.
Switched to the desired branch.
Found the commit that I wanted as the head of my new branch and right clicked.
Selected "branch."
My commit was already selected.
Name this new branch, create, and push.
Can also be done by selecting the "branch" button.
You then select the commit that you want as your new head, give it a name, and create it.