Showing posts with label GIT. Show all posts
Showing posts with label GIT. Show all posts

Monday, February 11, 2019

Git workflow to merge 2 branches



1. Switch to the branch you want to merge another branch

git checkout branch1

2. Execute merge command, here we are going to mcommandnch2 into branch1

git merge branch1

3. If conflict occures, manually resolve the conflict and add/stage the resolved files by executing

git add <file1 file2 ...>

4. Commit the merges.

git commit -m "message"

5. Push the changes.

git push origin branch1

Saturday, February 2, 2019

How to create an empty git branch


Sometimes we may want to create a different project (storing some documentation or some other files)inside our available repository. We can achieve this by creating a new branch by using normal "git checkout <branch-name>" command. But the correct way is

git checkout --orphan <branchname>


so that a new branch will be created inside the repo and automatically switched to the same. The new branch doesn't have a parent branch. We may need to execute the below commands to clear the cache and leftover files.

git rm --cached -r
git reset --hard


Once you created the orphan branch and after adding your new files, commit and push it. So that the branch will be available to all team members.