I was having issues with my faulty git commands, so I have multiple git commits but not the branches or repository.
git rebase -i HEAD~# doesn't have any of the faulty commit ids on the branches including master.
Is it still possible to delete them?
It's a little unclear what your situation is, but it sounds like you want to delete some commits, even though they aren't showing up on your branches?
If that's true, that the commits lie outside your branches, they may be on a merge branch which git creates temporarily. This is a branch just like yours, but is not as obvious to find.
Maybe try pasting some of your git status and git branch outputs with a little more info on your situation?
Related
My coworker and I are working in the same branch which was cut from develop. There are many files to be taken care of by both of us.
The scenario I’m facing is that
I did some changes and pushed my code to the remote repo. My coworker also did some changes in his local and and now he is not able to take a pull. It shows merge conflict while pulling.
Can someone let me know how can we resolve this?
Based on my understanding, I think we made some changes in the same files and now to merge them, git is causing that conflict.
First, make sure to use:
git config --global pull.rebase true
git config --global rebase.autoStash true
That way, a simple git pull will:
stash your work in progress
rebase your local commits (not yet pushed) on top of the updated remote upstream branch (instead of merging). That keep the history linear.
You can also activate rerere in order to not resolve the same conflict over and over again.
Finally, in case of merge/rebase conflict, you will need to chose between "our" and "their" version in each file with conflict markers. As shown here, an IDE can help facilitate the visualization and resolution of such conflicts.
I used tortoise git
git tortoise > git diff
Then I manually resolved the git merge conflict by removing or modifying the code I didn’t want.
Then I committed the code and the issues were gone.
I have a merge remote-tracking branch 'origin/master' in my timeline with a dozen changes since then by someone else.
I can't sync. When I try to revert and git revert --continue, it says can't commit because I have unmerged files. No idea what that means.
I looked at the files in question and there are no conflict there (the git comment blocks).
Also, these filed specifically have not been modified by anyone else.
How do I just force Github to take the folder from my current local folder and just move on?
I tried deleting the repository folder and recloning, but then it saied it can't clone. Took a while just to get it to clone. But still can't sync!
Thanks!
Try stashing your changes and then syncing/merging.
git stash
git pull
git stash pop
This should merge your local from upstream and have your changes which you can commit.
Note: In some cases, this might lead to a conflict depending on your code, but that should not be a big problem to solve.
Also, unmerged means that you have files that are not committed yet. Do a git status and it should show you.
I am quite new with Gitlab and I'm having an issue for merging in Eclipse.
We're working as a team, and we all have development branches that we are trying to merge into a single one. Unfortunately, when I did my merge, I have done a stupid mistake. Instead of merging my development branch to the main one, I have merged the main one into my development branch.
I have reversed the commit/merge on gitlab, but now as I try to merge back my development branch into the main one on Eclipse, it seems like I am 9 commits ahead of this branch (described as the arrows on Eclipse here: ), so the potential merge would basically replace everything by my code, when I should actually have merge conflicts to solve.
I am not quite sure how to merge properly so that I get back these merge conflicts.
Here is a screenshot of my network:
The ['1'] commit in the network on the left branch (my branch) corresponds to the merge from Week6AllIssues to my dev branch (the wrong merge). The last commit on this left branch is me reversing the commit.
Thanks a lot for your help !
If you're not using the remote branch with anyone else, the following series of steps might help.
First, remove the superfluous commits from the local branch. It can be achieved with git reset --hard <the commit before you merged master into your branch> command (see this link on how to do this with Eclipse).
Now make the remote branch match your local branch. You can do this with git push --force command. In Eclipse, this command corresponds to configure push - enable "force update" option.
Now the superfluous commits are gone.
I am using git-svn in my workplace since our current version control server is subversion and switching completely to git does not seem to be on the horizon for now (*cry*)
My workflow is as follows
I have the following branches
master tracks remotes/trunk
local/0.4 tracks remotes/0.4
work is my development branch for the master branch
work-0.4 is my development branch for the local/0.4 branch
I work in my work branches, then I merge to master and local/0.4 using
git merge --no-ff <branchname>
After that I check in to svn via
git svn dcommit
and I use
svn.pushmergeinfo=true
to update the svn:mergeinfo properties so my colleagues won't get angry with me messing up that metadata for them :)
However, I just had the following problem which stumps me.
I had done two commits on the work-0.4 branch, then I merged these to my local/0.4 branch with git merge --no-ff work-0.4. After this, I did git svn dcommit and recieved the following message
Committing to https://svn-server ...
e138050f6ebd2f2ca99cbefc5e48acae412e1f86 is merged into revision f5f2345e8e5fc64
20423bdc00397b5853b3759c4, but does not have git-svn metadata. Either dcommit the
branch or use a local cherry-pick, FF merge, or rebase instead of
an explicit merge commit.
After some rebasing and reset'ing of branches I managed to push everything to svn, but my solution entailed doing a rebase of my local/0.4 branch to the work-0.4 branch which in turn meant that I did not get to squash my two git-commits into one svn-commit :/
I feel that I'm probably doing something wrong with my workflow here, and it might be related to svn.pushmergeinfo. The docs for svn.pushmergeinfo says
config key: svn.pushmergeinfo
+
This option will cause git-svn to attempt to automatically populate the
svn:mergeinfo property in the SVN repository when possible. Currently, this can
only be done when dcommitting non-fast-forward merges where all parents but the
first have already been pushed into SVN.
and to be honest, I'm not quite sure that I understand that correctly? Am I doing something weird here that makes svn.pushmergeinfo not work correctly? How should I structure my workflow to optimally work with git-svn correctly (setting proper mergeinfos etc)?
I am recently learning git, and found people can delete short branches, but in Hg, after merging the branch to default, how could I delete it?
You cannot. You can close the branch to hide it from the list of active branches, but you cannot completely delete it.
This happens because in mercurial and in git the "branch" term means different things.
In mercurial - it is a set of changesets.
And in git - it is a pointer to a particular changeset.