I am pretty new to Git.
I have created a repository and added some files to the master branch. After that, each time wanted to work on a particular subproject, i have been doing “create new branch” with a name for example “csv_reader_branch”, “datetime_object”.
Now i have many branch and would like to push those branches to the master branch. Normally the projects are non overlapping but i would like to be able to compare before merging.
What is the best practice?
PS: also I see “fork” mentionned on many similar question but i am running git locally and cant find any “fork” in the github menus. Am i missing something?
Regards
with
git diff branchname filesyou can compare your current branch with other branches of your repository.To apply the changes of your branch to your master, you have to checkout to your master branch and use
git merge branchname.Another possibility is to “cherry pick” a specific commit, but be warned, it doesn’t apply only the cherry-picked commit but all preceding commits since your branch split from master.
A third possibility, if you want to only apply one commit and only, is to use
git format-patchin your branch and apply the generated file(s) to your destination branch withgit apply.EDIT: I forgot, there’s a 4th possibility with using
git rebaseinstead ofgit mergebut honestly, I would avoid to use it before being really good in using git.In any case, the difficulty is in resolving merge conflicts that occure when the same part of your files have been edited in the 2 branches.