I made a wrong Merge and now would like to remove my last local commit, is there any way to do it from Eclipse?
Look under Undo. As long as you haven't pushed your merge commit anywhere else you should be able to "rollback" or "strip" the merge commit.
Make sure to back up your whole repository before trying it out though.
Related
I am working on a branch (feature01) and it is still work in progress. Now I have to leave the WIP branch and start working on another feature/bugfix and for that, I have to create a new branch out of my development branch. I usually stash all the changes in feature01 and start working on a new branch. I don't like this solution that much as I can be working on the new branch for a day or so and I have to remember that there is something on the stash. Is there any localized version of stash for each branch or something of that sort so that I can move around between different WIP branches without having to stash a bunch of stuff and keeping track of them manually.
One solution I was thinking of was committing the local changes before checking out to a new branch and then later when the work is done on one of the WIP branch, I can squash some of the commits together with a more meaningful message rather than having a bunch of commits with not so helpful messages.
I would like to know if you guys know better solutions to this problem or if this problem is arising because my git workflow is not correct. I searched for solutions online but most people recommend stashing which I don't like much when the changes stay for a longer time in the stash.
Cheers.
Waqar
I'd suggest using a temporary commit :
# you have unfinished modifications to save before switching
git commit -am "temp - DO NOT PUSH"
git checkout other-branch
Then you can work on the other-branch, and when you're done, it's easy to undo the commit on previous-branch while keeping its contents
git checkout previous-branch
git reset HEAD^
Of course, it's easier when you have aliases
git config --global alias.ct 'commit -am "temp - DO NOT PUSH"'
git config --global alias.rs1 'reset HEAD^'
Then just
# to save uncommited changes ON the branch
git ct
# to "unravel" a temp commit
git rs1
Instead of stashing or doing a temporary commit, another solution is to use the git worktree feature to work in another folder (but still within the same repository).
A blog post on the subject: https://spin.atomicobject.com/2016/06/26/parallelize-development-git-worktrees/
Git uses commit id's such us 521747298a3790fde1710f3aa2d03b55020575aa.
This hashcode keeps every changes in your code. if you want to change your branch without commit, its not logical according to git rules. Every changes must be marked with this hashcode. To extend you can choose which commits must be push.
I need to push a commit into two or more branches as the same time, using Git and Netbeans. Those branches are not local, but in BitBucket and shared with others developers.
The situation is this:
We have a branch which is used as a master (soon we will rebase it) and we are working on an another one. WHen I find a problem on the older branch, I'll switch to that and do the modification, then commit. I want the pushed code to be merged also with the newer branch.
How Can I do ?
There are a couple of ways to approach this, sounds to me like the simplest one in this case might be to use git cherry-pick to copy the commit from old-branch to new-branch locally on your machine, then push the revised new-branch back to Bitbucket.
The alternative way would be to create a PR on the server from old-branch to new-branch, whether or not this is viable will depend on what else is in old-branch that you don't want to copy across.
Thanks to all. I tryed a cherry-pick trough Netbeans git plugin and it worked perfectly. Now just have to guess if it add only committed lines or if it merges the entire files in the pick. I'll do some tests. I'll try also the pull request, sooner or later.
A file has been changed both locally and remotely.
I would expect to be able to solve the conflicts.
However when I execute a "git pull" with IntellilJ, I get the following message: "Git Pull Failed. Your local changes would be overwritten by merge. Commit, stash or revert them to proceed."
What I need to do to merge the local changes with the remote changes, then commit and push?
When you have changes that aren't committed to your own repo in any way, git doesn't have any way to know how you would want the pull to affect your files in the current state.
Another way to look at it is that the git client won't let you change files which are modified.
If you wish to discard your local changes, you can revert them. If you wish to commit them to the repo, then just commit. If you wish to keep the changes for later but they aren't going into the repo just now, you can stash them. You can read about these commands in the progit book or any other resource online, if you're not sure what they do. Good luck!
Do a commit on the stuff you have in your local workspace, then pull.
This may be a stupid question, but after several times trying to get this right I'm getting frustrated. I want to use github to host my project, we are 2 people working on the project and the aim was to share the work. And help each other.
I managed to create the resepetory, and committing to master branch. If the other guy deletes the whole project he gets the latest updates, but I'm sure this is not the way its supposed to work.
Lets say I commmit a new class file. I commit this file, how could the other person download this file? We've tried pull, synchronize etc etc without any luck. The only way we have found to give him "my" latest updates is for him to delete all content and make the project from scratch.
What am I missing? How can we synchronize workspaces? So I can see and download his changes when i open Eclipse? (We are not working in the same class). So really all I want to do is download he's latest commits.
EDIT : My solution was that my partner was working in a copy of the local git workspace. So instead of modifying the local repo he was modifying a copy of it inside the Eclipse workspace. And because of this nothing updated when he did the pull. I also switched from Egit to GitHub command line tool, and I'm in love. Thanks everyone :)
Normally with GitHub, all of what you have described works perfectly, I have not had any kind of similar problems.
One thing about git, a commit is a bit different than a commit in SVN. With git, you use push and pull to interact with your remote repository.
I am not sure what you mean when you say:
If the other guy deletes the whole project he gets the latest updates,
but I'm sure this is not the way its supposed to work.
That being said, I have never used Egit, I prefer to stick to the command line for all my git needs. I have had issues with other software (Sublime Text 2) where I would have to exit the editor, then run all my commits and other git actions. I do not know how well Eclipse plays with git in general.
Try to have your partner run git remote -v just to make sure he is tracking the repo properly. Also, do you know if he set up an SSH key for GitHub, or you sending your pushes and pulls via https?
Keep in mind this is pretty hard thing to help you out with since I am not sitting at your computer. GitHub Help has some very good walkthroughs on setting up git and remote repositories.
Also, I highly recommend the time to go through CodeSchool intro to git. If this is your first time using Git, this is the best starting point.
There are much more complicated scenarios, but basically, you need to "push" your commits to the upstream, and pull your colleague's.
Clone the repo. By cloning it you will guarantee that it has an "origin", the github remote. You make changes in your local repo, committing them as you go. When you are at a milestone, use Team > Push to push all of your commits to github. Your colleague will pull them, as described below.
When you try to push, you may discover that your colleague has pushed changes and that git will not allow you to push until you merge. Try Team > Pull which will merge the remote changes into your local repo. If there are no conflicts, you can now push. If there are conflicts, fix them and then commit. Then push.
This is a substantial simplification but may get you started. The main point is that the equivalent of a SVN commit is, in git, two, maybe three, operations: add, commit, push. Git pull is vaguely analogous to SVN checkout.
Take a day to read up on git. There's great documentation at GitHub. Once you get the hang of it, you'll love it.
When using git to collaborate on a project, you are managing both a local and remote repository. When you commit, you are only saving changes to your local repository. After committing, you need to do a push in order for your changes to be saved to your remote repository. After doing that, if your collaborator does a pull he will get your changes.
My situation is this: I work on a java project in eclipse and use Subclipse for source control. Recently, work on a branch was completed and reintegration was attempted. However, my (shitty mobile) broadband connection decided to bug out about 75% through the merge to trunk. Now, whenever I retry the same merge I get the error
"Filesystem has no item
svn: '/forge/!svn/bc/15895/trunk/branches/AbilityWork' path not found".
Since the actual reintegration was not done, is there some way to work around this and get a chance to complete the reintegration or perhaps some roundabout way to "rescue" the changes in the branch since they were quite involved.
Thanks in advance for any and all assistance!
If you say "merge" it means an operation on your working copy. So you could revert your working copy(all changes are undone) and start over with your merge again.
You need to commit your merge to "finalize" the result in your subversion repository.
As Subversion is transaction based, it is not possible to commit half of a merge. then nothing would be commited(transaction rollback).