Reputation: 5055
I am using git for a weeks now. I am working in a feature branch, sometimes when I push code into my branch it shows lot of conflicts with develop branch. so I this time I followed following steps to avoid unwanted conflicts and problems at work place :(
git branch abc
git checkout abc
Now these step resulted in committing of 2 files, one in which I resolved conflicts and one in which I worked. Say File1 and File2 respectively.
Now I need to re push my code but only file2 i.e one in which I worked not in which I did conflict resolving and all.
But git status will show nothing as I have already done all the committing and pushing. Also during some of the auto-merging the necessary code is removed from File1. How to bring that back?
Any help would be appreciated?
As I am still learning GIT so any explanation would help me and others.
I am using BITBUCKET.
Thanks!!
Upvotes: 0
Views: 1831
Reputation: 11
To extend previous answer, I would add: Git stash will save your changes in a "pocket" if they are not ready for a commit. But your changes are ready, so it is not necessary.
About your question in previous comment (I do not have enough reputation for answer you in a comment): git pull update your local repository and your working directory with the changes in the remote repository, is a shortcut for git fetch followed by git merge. But, as git merge have some drawbacks about the history, could be useful to used git fetch + git rebase instead.
Git rebase works locally, so it could be used in an homologous way to git merge, but not git pull!. Many answers will explain better than me about git rebase, I hope to help a little bit.
Upvotes: 1
Reputation: 2685
For #1 & #2: They can be combined -- git checkout -b abc
For #4: Why did you stash? I believe you should have committed your changes here.
For #6: Conflicts where? On your newly created feature branch? That shouldn't be possible.
A typical work-flow would be as follows:
git checkout master
git fetch
git rebase origin/master
git checkout -b featureBranch
git add .
# This is just one example; add selectively, as-is appropriategit commit
git push origin featureBranch
git checkout featureBranch
git fetch
git rebase origin/master
git checkout master
git rebase origin/master
git merge --no-fast-forward featureBranch
This workflow, via rebasing featureBranch before merging & using non-fast-forward merging, will result in a linear, yet delineated, history of master.
Good luck!
Upvotes: 1