Currently am working with Git Repo and i have a fellow team mate also ,after he commit to the remote repo and i get all the changes . I have couple of questions
When i merge the code with Changes then the changed file in my work space is marked as staged, do i need to commit to local repo?
I have a read lot of documentation and still am confused with the best way of sync,
Currently i do following steps:
Go to Team->Sync Workspace-> Fetch From Upstream->Mege . Please correct if am wrong
Note, the Egit manual includes a "pull" operation which would do the fetch+merge in one operation.
Right-click on a project in the Package Explorer and select Team > Pull or right-click on a repository in the Git Repositories view and select Pull to pull new changes from the upstream branch your local branch is tracking.
Doing a fetch + merge (as in Egit Merging) will result in a merge commit unless there is a conflict.
Real merge: When neither of the conditions above apply egit triggers a merge of the commits. There are two possible outcomes:
If no conflicts occur the current branch will point to a newly created merge commit;
if conflicts occur the conflicting files will be marked with label decorators (see Resolving a merge conflict for further actions in case of merge conflicts).
You should see staged changes only in the second case (merge conflict to resolve), or you would see stage changes because you previously added to the index files which are not part of the merge (they remain staged until you commit them)
Related
I am working in a team on Selenium WebDriver in Java. For eg. If I and one of my team member are working on the same file. Every time someone commits some changes into the repository and when I pull the code, eclipse shows conflicts even if a new line of code has been added to the file. Is there any way to merge both the codes without this conflict?
Maybe try to do it that way :
git add [your file]
git commit "fix"
git pull origin master
git push origin master
The conflicts may occur because you don't commit your changes before pulling from the repository.
Using gitHub (and Eclipse Egit, and SourceTree) with a forked repo, how can I make a pull request that just contains a few select files I want pulled?
This question asks almost the same thing, but addresses 'cherry-picking' a single or group of commits. I seem to need to have a pull request with just a few files from within a larger commit.
I tend to make a lot of changes to a lot of files putting in debugging code then find a solution that may involve only a change to a file or two. I don't commit very frequently so I don't have have a commit that contains only the changes that fix the problem (and I like keeping the debugging hooks in my copy of the code.)
I'd like SourceTree or eGit/Eclipse to: 1) show me which files are different between two commits and 2) let me select which files to include in a pull request. Perhaps I could do some selective merge files in my current master head and the master of the upstream repo?
I think what you want to do is to check out a number of files from a given commit / tree / revision.
To do this use:
git checkout [tree-ish] -- [paths]
[tree-ish] is a git-ism that basically means a commit, tag or branch, or something that refers to one of those. So if you have a remote remotes/foo/bar and you want baz.c from that revision, you do:
git checkout remotes/foo/bar -- baz.c
A 'pull request' is not a git thing, but a github thing. You will need to do a git remote add to add the repo you want to pull, then use git fetch or git remote update to pull the relevant information, then use the appropriate branch name in the above to get the file(s) you want.
I have Branch A and Branch B in the local branch folder.
Branch A is under working.
Now I want to switch to B.
The window pops out:
Checkout Conflicts
The files shown below have uncommitted changes which would be lost by checking out 'master'.
Either commit the changes, stash the changes, or discard the changes by resetting the current branch.
project.properties.
There are 3 options:
Commit..
Stash...
Reset
No matter which option I choose, it does not work.
For example, if I choose "Stash" option, it says:
"The repository does not contain any local changes to stash".
I suspect the egit records have some conflicts, so it cannot know how to do the next step.
The only way:
To remove the local branches, and clone the remote repository to the local?
This needs cost some time for downloading.
I had the same problem. EGit complaint about .class files which were not commited. I deleted the .class files and was able to switch to the desired branch without problems.
IMO removing local branch is not required.
I suggest first to pull the remote changes to local Branch A.
Resolve any conflicts while pulling the changes if any. Refer this video
Add your changes to Git staging area just by dragging the the files from unstaged area to staged area refer pic below.
Click on commit button, then push the changed to remote branch.
After doing this Branch A will be clean, then you can switch to Branch B just by double clicking on it or by right clicking on the repository node and selecting Switch to option in Git repository view.
Also I suggest to use the latest stable Egit plugin from here
I often see the below errors on doing git pull on totally untouched files which I am NOT working on.
Pull is not possible because you have unmerged files
It is clear the conflicted files have changed in the git repo. But I don't understand why git pull cannot over-write on these untouched files - which I've not touched?
What can I or my team do to avoid getting these errors?
Edited -
Along with the solution I want to understand why the errors are coming.
Just to make clear, the other team members are working on other files (say xyz). And I am working on a separate set of files having no dependency on xyz files. So if I pull the repo changes after a long time with no changes from my side in xyz, why the conflicts in those files?
use git diff to see problem files
look at this git cheat shets for usefull commands
http://www.cheat-sheets.org/saved-copy/git-cheat-sheet.pdf
http://jan-krueger.net/wordpress/wp-content/uploads/2007/09/git-cheat-sheet-v2-back.svg
There are some tips from my own experience. i'm not sure whether they're 100% corerect)
Split work with your team on paralel threads. Try not to work in the same files.
Try to avoid situations when 2 or more persons are adding new files simalteniously. When one added new files others should make pull as soon as possible
the last but not least - make git push very often. this will keep your project git up to date
Since git pull does not pull individual files, it's git merge phase will stop for manual correction of any merge conflicts. git merge and/or git pull (and by nature of the fact that git pull is essentially git fetch followed by git merge) is an all-or-nothing operation - you either successfully merge the changes introduced on both (or all) of the branches you are merging together, or you don't merge any of them. The catch in that is when conflicts arise that must be manually resolved - but in that situation, you are in an in-between state, having neither completed and committed the merge nor rolled it back to your previous state.
The message you are getting implies that you have previously done a git pull or a git merge, which stopped in the middle, requesting that you manually resolve some conflicts, which you have not yet done, but have rather continued on doing other stuff, and are now trying to do another git pull / git merge without ever having completed the first one.
Take a look at git status, and follow the suggested directions for either resolving your in-progress merge issues or resetting back to a not-in-the-middle-of-a-merge state.
I am using Git to share my code with my team and Eclipse as my IDE. I have installed the EGit plugin for Git functionality. The problem is that I am not sure what the correct steps to sync my local branch with the remote one are (something like: 1. Right click on your repository and team->fetch 2. Pull 3. and so on...).
Currently I know that first I have to fetch (this will update my remote branch) and next I need to pull. Let's say there is a conflict between the remote and local branch; how should I resolve it?
I have read a lot of tutorials on the net, but it seems that my case is too obvious to explain elaborately.
Currently I know that first I have to fetch (this will update my remote branch) next I need to pull
No, you can pull directly: it combines a fetch and a merge.
Any merge conflict that might arise during a pull will be handle like any other merge
If your merge resulted in conflicts (note the red symbols on the file icons), you will have to resolve these manually. Open the conflicting files and scroll to the conflicting changes marked with “<<<<<<<”.
After you are finished the manual part of the merge, you will have to tell Git that the conflicts are resolved. To do so, Add the files and Commit to complete your merge.