- From branching, merging to conflict resolutions.
- clone the master repo into a new folder
git clone --recursive git@github.com:khanalg44/AllAboutGit.git new_branch
- Go inside the directory
new_branch
cd new_branch
- Create a branch
git branch new_branch
- Checkout to the new branch
git chekout new_branch
- Now add a file (file1) and push it to remote.
git add file1; git commit -m 'added new file'; git push
- Go to the directory with master branch and do git pull so that the master branch knows about the newly created branch
new_branch
cd <master_branch>; git pull
Once the local changes are commited and pushed you can merge the master to your branch.
- Go inside the branch and merge the master branch
git merge origin/main
- Push the changes to the remote.
git push
- Assuming the code is added annd already commited to the repo. The following will undo the commits without removing the local changes. (Stack Overflow link)[https://stackoverflow.com/questions/4114095/how-do-i-revert-a-git-repository-to-a-previous-commit]
git reset HEAD~1