Git and GitHub Beginner Tutorial 5 - Branching and Merging
ฝัง
- เผยแพร่เมื่อ 6 ก.ย. 2024
- Git and GitHub Beginner Tutorial 5 - Branching and Merging
Today we will learn
-----------
1. What are branches
2. How to create branch
3. How to checkout branch
4. How to merge branch to master
5. How to delete branch (local and remote)
_________________________________________
Step 1 : Create branch
git branch “branch name”
Step 2 : Checkout branch
git checkout “branch name”
Step 3 : Merge new branch in master branch
git merge “branch name”
Step 4 : Delete branch
git branch -d “branch name” - delete from local
git push origin -delete “branch name” - delete from remote
_______ ONLINE COURSES TO LEARN _______
Visit - automationstep...
----------- UI TESTING -----------
Selenium Beginners - bit.ly/2MGRS8K
Selenium Java Framework from Scratch - bit.ly/2N9xvR6
Selenium Python - bit.ly/2oyMp5x
Selenium Tips - bit.ly/2owxc50
Selenium Builder - bit.ly/2MKNtlq
Katalon Studio - bit.ly/2wARFdi
Robot Framework - bit.ly/2Px6Ue9
----------- API TESTING -----------
Web Services (API) - bit.ly/2MGafL7
SoapUI - bit.ly/2MGahmd
Postman - bit.ly/2wz8LrW
General - bit.ly/2PYdwmV
----------- MOBILE TESTING -----------
Mobile Playlist - bit.ly/2PxpeUv
----------- CI | CD | DEVOPS -----------
Jenkins Beginner - bit.ly/2MIn8EC
Jenkins Tips & Trick - bit.ly/2LRt6xC
Docker - bit.ly/2MInnzx
----------- VERSION CONTROL SYSTEM -----------
Git & GitHub - bit.ly/2Q1pagY
----------- PERFORMANCE TESTING -----------
JMeter Beginner - bit.ly/2oBbtIU
JMeter Intermediate - bit.ly/2oziNVB
JMeter Advanced - bit.ly/2Q22Y6a
JMeter Tips & Tricks - bit.ly/2NOfWD2
Performance Testing - bit.ly/2wEXbLS
----------- JAVA -----------
Java Beginners - bit.ly/2PVUcXs
Java Tips & Tricks - bit.ly/2CdcDnJ
----------- MAVEN -----------
Maven - bit.ly/2NJdDRS
----------- OTHERS -----------
Redis- bit.ly/2N9jyCG
Misc - bit.ly/2Q2q5xQ
Tools & Tips - bit.ly/2oBfwoR
QnA Friday- bit.ly/2NgwGpw
Sunday Special - bit.ly/2wB23BO
Ask Raghav- bit.ly/2CoJGWf
Interviews - bit.ly/2NIPPxk
All Playlists - bit.ly/2LSiezA
----------- Follow -----------
Facebook - / automationstepbystep
Twitter - / automationsbs
TH-cam - / automationstepbystep
You can support my mission for education by sharing this knowledge and helping as many people as you can.
I've watched about 3 videos on Git and honestly your tutorials are the only one where I understood it. You explain everything so clearly and at a great pace. I'm so glad I found your channel.
I am glad you found it useful. Keep Learning !
True @westfield90
i really love how you add a little bit of repetition to your videos to make us use what we learnt. It also allows us to understand exactly whats going through in your head. good job well done keep up the good work.
You are so welcome Jeremy
I liked how you explained everything step-by-step and in a concise manner.
Thanks for watching Sammy
Hi Raghav, Thanks for Tutorial. You explain in very simple way I understand all git commands properly.
You are most welcome Gourang
Excellent tutorial, complete yet succinct and straight to the point. Thank you so much
Most welcome Andres
Manish...Thanks for Your hard work and uploading the stuffs for the Community, Really excellent and extraordinary explanation . Thank you Again..Now I can add my framework to git repository...Thank you sir............................
Most welcome. all the best Manish
Raghav i had see more then 4 git videos from diffrent persons , but i understand now , thank you..
So happy & humbled to know this Rohith
Very good thanks
You're welcome
Your educational content, Raghav, is top-notch! 🚀 Clear explanations and well-chosen examples make learning a breeze. Thanks for expanding my knowledge. Keep the outstanding work coming! 🌟💻📚
Thanks a ton
Hello Raghav, Thank you for nicely tailored Git, web services and Jenkins tutorials....
I am glad you found it helpful
Simplest and best git tutorials for beginners. Good job, Raghav!! Keep posting. Thank you.
You're welcome Umesh
Your entire channel is very informative and precise. Much much regards to you Sir.
So happy & humbled to hear that Aditi. Thanks
Hi Raghav, Your all 5 tutorial on git are awesome. First time i am able to understand git from your video. Thanks to post such awesome understandable video. Please keep it posted for further topics on git.
Great to hear this Nilesh, i will keep adding more interesting and useful videos.
I have watched so many videos for this, but i got from your video thank you so much
So happy to know this Srinivas
I am really a big fan of your style.Thank you uploading the videos
Most welcome
Clear and to the point. Great video to get started with Git Branching!
Thanks Aditya
creating a new branch and checking out to it.... let's make the command more compact "git checkout -b new_branch"
thanks for sharing Mukesh
please dont stop making videos.. u make concepts easy to understand
Sure, I will continue this. Thanks Farnaaz
Thanks, Raghav! Easy to understand.
Most welcome Srikanth
Hi Raghav sir can you please share the step to follow all activity in IDE instead of command prompt
I will plan on this Shaira
Good job brother . Hats off to your way of simplifying the complex things and all your efforts.
Thanq very much for all your efforts
You're welcome Vijay
Salute to your efforts. Awesome video for anyone to understand. Thanks!
You're welcome Ankit
I have been recommended to set up a branch for each developer where I work. Is that something you consider to be good practice? It's different to your example here where you have code being written for a specific purpose and then deleting the branch when the objectives have been achieved. Our branches are permanent.
Phil
Whether or not it is good practice to have a permanent branch for each developer depends on a number of factors, including the size and complexity of your project, the number of developers working on the project, and your team's workflow.
*Pros of having a permanent branch for each developer:*
*Improved isolation:* Each developer's code is isolated from the code of other developers, which can help to prevent conflicts and merge issues.
*Increased visibility:* It is easy to see what code each developer is working on and what changes they have made.
*Enhanced collaboration:* Developers can easily share code and collaborate on features by merging their branches into a shared development branch.
*Cons of having a permanent branch for each developer:*
*Increased complexity:* Managing a large number of permanent branches can be complex and time-consuming.
*Reduced visibility of the codebase:* It can be difficult to get a holistic view of the codebase when there are many different branches.
*Increased risk of merge conflicts:* Merge conflicts are more likely to occur when there are many different branches.
*My recommendation:*
I would recommend that you start with a temporary branch for each developer. This will give you the benefits of isolation, visibility, and collaboration, without the complexity of managing a large number of permanent branches.
Once you have a good understanding of how your team works and how your project is structured, you can decide whether or not to switch to permanent branches. If you do decide to use permanent branches, I recommend that you implement some best practices to help manage them effectively.
*Best practices for managing permanent branches:*
*Use a branching strategy:* Define a branching strategy that outlines how branches will be used and when they will be merged into the main development branch.
*Implement code reviews:* Require all code changes to be reviewed by another developer before being merged into the main development branch.
*Use a merge tool:* Use a merge tool to help resolve merge conflicts.
*Automate testing:* Automate testing to ensure that code changes do not break the existing functionality.
Having a permanent branch for each developer can be a good practice, but it is important to weigh the pros and cons carefully before making a decision. If you do decide to use permanent branches, be sure to implement some best practices to help manage them effectively
@@RaghavPal Thank you so much! 🙂🙂🙂👍👍👍
Awesome explanation
Glad you liked it Uday
Excellent Explanation. Can you make video for git feature branch workflow ?
Hi Sadat, yes will plan
It was really helpful. Thanks a lot for such great video.
Most welcome Noorein
Quick Question: The code in Git does not match the actual code in production, how to over come this? what strategy should be included?
Hi Shireesh, are they on 2 separate branches, you can merge the branches. Do watch merge and rebase video th-cam.com/video/KWAZl2QHC44/w-d-xo.html
great explanation
Glad it was helpful Suresh
Hi Raghav,
The way u explained is very clear and understandable and its very useful for us. It could be better if u can upload more videos on the commands like rebase,stash and so on.
Thank you in advance
Glad to know this Rajeswari
I will do more videos soon.
Raghav bro, if you could give the steps in windows machine also it would be very helpfull
Hi Sourav, the commands should work on git bas from windows too. Was there anything specific that you could not follow on windows. Pls let me know.
@@RaghavPal yes Raghav, If its ok I can send screenshot and also discuss in person about it. I have dropped an email please kindly check
Ok Sourav
Hi Raghav,very nice tutorial.
I have tried everything which you have showed,I have one doubt what is the difference between master and origin/mater or mynewbranch and origin/mynewbranch.
Hi Richa, i am happy it helped you.
origin refers to the remote repo (url) set as origin. You can set origin with this command
git remote set-url origin github.com/USERNAME/OTHERREPOSITORY.git
master is the branch. You can also use any other branch .
At 6:12 why have you used -u orign and not just git push since you are already no the MyNewBranch?
Hi Nipun, yes, you may skip -u here
best videos ever
Thanks Ishak for watching and learning.
I got an error while pushing after merge. The error is " rejected. master -> master (fetch first). Error: failed to push some refs to the location".
Hi Aditya, Did you trying doing a fetch first. This will help you - stackoverflow.com/questions/28429819/rejected-master-master-fetch-first/28429887
Very informative video.
as i am from Linux admin i can understand easily but lag in few terminologies like branches commit clone etc as i am unfamiliar with these terms
Hi Manikanth, i created this series for beginners and i hope you should be able to get most of the things even if you do not know it earlier. In case you still want some deeper knowledge or info, you can search for the particular term on internet. You will find all the info you need.
Thank you very much for this tutorial
You are welcome Shubham
Hi Sir, Could you please explain the concept of resolving merging conflicts on GIT?
Hi Suman, I will try to create a session soon.
Thank you so much. I really appreciate your helpfulness.
You're welcome
I have confusion in branches, Suppose, we have created two branches named "Master" and "MyBranch" and what if we have two same files in both branches and we update them parallelly in both branches. Now, we have committed our changes in both branches and we want to merge "MyBranch" into "Master" branch, what will happen?
If merge conflict occurs then how can we remove those merge conflicts because we might have lot of changes in both files and finding both changes could be difficult.
Suppose, we found errors in "Master" branch and some other errors in "MyBranch" and we have fixed both errors on both side, After that, we merge branches then how can we remove merge conflict.
I Hope you got my point, I'm new in Git and GitHub.
I look forward to hear from you.
Hi Imtiaz, there are ways to handle the merge conflicts and changes. I will plan to create a session on this
@@RaghavPal Thank you very much and I look forward to see you again in an other video.
Hii sir can we use -b for direct create a branch and log into it and after delete branch locally we also use git push origin :branchname for dlt remote ly
You can
Thank you so much, explain everything clearly.
Thanks for watching.
Great tutorial series. Very informative.
Thanks for watching
Hello Raghav Pal! First of all, thank you for the videos you upload, I have a question with regards to branching and merging: Why the branching and merging are not seen as contributions on the GitHub profile page (the green squares), or should those be seen at all? The reason I ask, is that I want to track my progress, and I want it to be visible on the contributions calendar bar. Thank you!
Hi Vasile, I am not too sure and will need to get some online help on this
hi addVideo 5:-
Git and GitHub Beginner Tutorial 5 - Branching and Merging =
Today we will learn
1. What are branches :-we create branches we do perform testing and then only we add folders to master branch so that whole functinality don’t get effected
Go to cmd prompt-go to path of folder in gitnow u r in folderenter git statusnothing to commit tree is clean
2. How to create branchnow add branch by cmd git branch mynew branch
3. How to checkout branch to start working on branch u have to check out using cmd git checkout branchnamenow whatever changes u make to folder will go to project folder now add text.txt file in the foldergit statusgit add . git commit -m “added text.xtxt file”git stautus nothing to commit git push -u origin mybranch-> now u have two branches one master and mynewbranch in new branch only u have test.txt if cmd git checkout master in folder also u don’t have test.txt file
4. How to merge branch to master u have to checkout master and then merge mynewbranch
cmd git checkout mastergit merge mynewbranch git push -u origin master
5. How to delete branch (local and remote)
git branch -d “branch name” - delete from local
git push origin -delete “branch name” - delete from remote
Hi Zulfquar, will check this
Please share me any high level process for GIT branching and tagging with flow diagram
Hi Sharmila, sure, I will do a session
hi, I am working on one RFP, need the w information.@@RaghavPal .
1.why we want to create new git branch instead of old branch
2.how we can able to handle fail safe mechanism incase of any wrong commits to the repoistory
3. How will copy the changes from master branch to new branch by using tagging/merging
4.jenkin job updated to add new git parameters
These 4 points I need to present with any diagram
Hi Sharmila,
1. We create a new branch mostly to develop a new feature. So that if anything goes wrong we can revert to the original branch
2. This is where we try to create new feature in new branch so our original work is intact in the older branch, Also we have option to revert to any earlier state. Tags will be very helpful here. Check the video on tags. You can easily revert to any older tags in case any problem occurs
3. There is a video on Tags and Merging. Pls check
4. If configured Jenkins will take the latest changes from git. Not sure what else you meant here
Thank you very much for your explanation but what is the purpose of the branch?
Hi Walid, Branch is like a parallel version of the code that can be modified without affecting the other versions.
Raghav - How can we undelete the deleted Branch in case we need it. Pls suggest.
Hi Sahil, you can use the *git reflog* command. Check this - confluence.atlassian.com/bbkb/how-to-restore-a-deleted-branch-765757540.html
Thank you so much for your time and effort, for sharing your knowledge with us. Thank you and keep the good work.
Thanks Wilson, appreciate your message
great video
any video for resolving conflicts using gitbash
thanks
what is the issue you are facing
if two users edit the same file there will a conflict
and it will not merge
Well Done!
Thanks
HI Raghav ,Thanks for ur videos.I have one query, like if I am making changes to my file everyday,,, eg ver1,ver 2,ver3 and then suddenly while working on ver3 i wanted to see my previous file ver1, how will i get that.Also what will happen if i keep on modifying same file without committing it.
Hi Anjali, you can always go back to any previous commit. I believe I have explained that in some video. Every commit has a commit id. If you run command
git log
You can see the commits and id. You can do git checkout "commidid"
Here are more links to help - stackoverflow.com/questions/4114095/how-do-i-revert-a-git-repository-to-a-previous-commit
@@RaghavPal Thanks Raghav for the reply. Yeah you explained it in "tag" video.I came across that video later ..thankyou
Nice explanation
Sir but if i have two or more repo then how does the git know to which repo this branch will be pushed?
We provide branch name while pushing
thanks Raghav for the tutorial
You're welcome
Do we need to use git branch if we are using checkout ?
Hi Vinod, yes, you need to do it on a branch
How to check - which is active branch if there is more than one?
OK , git branch --list , is the command. * shows active branch
Hello Raghav, Do you have any tutorial to migrate from CVS to GIT or CVS to GITLab?
No Chetna
hello i am super confused there is 3 branches --main, MyNewBranch, master--where does main come from? --im so confused mixed up--anyway master is merged and up to date on local and remote repos Lisa
Hi
The "main" branch is the default branch name for newer Git repositories created on GitHub. In the past, "master" was the default branch name, but GitHub recently changed it to "main" to avoid any language that may carry a negative connotation.
Regarding the confusion with branches, it's important to keep in mind that each branch represents a different line of development within a Git repository. The "master" branch is typically used as the main branch of development, where all changes are merged into, and should always represent the latest stable release of the code.
In your case, it seems like you created a new branch called "MyNewBranch" to make some changes to the code. Once you were done with your changes, you merged the changes from "MyNewBranch" into "master" and pushed the changes to the remote repository. This should have updated the "master" branch on the remote repository to reflect the changes you made on the "MyNewBranch" branch.
If the "master" branch on the remote repository is not reflecting the changes you made, it's possible that the push did not go through correctly. You can try running the command "git log" to see the commit history and confirm that the changes were indeed merged into the "master" branch before attempting to push again.
Can git repo be managed without the command line as in if I have to integrate any application so that i can use it as version control and I already have a public online repository available, so can i manage to push the code on git
Maddy
You can manage a Git repository without using the command line. Here are a couple of ways to achieve this:
1. GitHub Desktop:
- Use [GitHub Desktop](docs.github.com/desktop/contributing-and-collaborating-using-github-desktop) to interact with GitHub using a graphical user interface (GUI).
- It allows you to perform most Git commands (e.g., push, pull, clone, commit) directly from your desktop.
- Visual confirmation of changes makes it user-friendly.
2. GitHub Website:
- If you prefer a web-based approach, use the GitHub website.
- Create, manage branches, commit changes, and open pull requests-all without the command line.
Choose the method that suits your workflow best
What if you want to add different directories in a repository like school management system which have multiple modules each module is one software on it's own(one file directory on it's own) is it best to add each one in different branches ?
Yes you can create branches
Hi Raghav, Can you help me: fatal: bad numeric config value 'exit' for 'color.ui': invalid unit
-->How to resolve this? I am using windows.
Hi Dasari,
Run this command
git config --global color.ui false
and then try
OR
Run command
git config --global --edit
Then in the editor change the value of "status" to "auto" and save.
How can we run a test project from the branch? I am confused. Thank you in advance.
Hi Mohammed, you just have to checkout the branch and then all commands will run on that branch
git add -A , git add* and git add . all are the same commands??
No, `git add -A`, `git add *`, and `git add .` are not exactly the same commands, although they have similarities. Let's break down each one:
1. **`git add -A`:**
- This command stages all changes, including modifications, deletions, and new files across the entire repository. It stages everything.
2. **`git add *`:**
- This command stages all changes and new files in the current directory. However, it does not consider files or changes in subdirectories.
3. **`git add .`:**
- Similar to `git add *`, this command stages all changes and new files in the current directory. However, it also stages modifications in subdirectories.
Hi Raghav , To create a new file, $ Touch (or) dir> "", which on e to use?
Amarnath
To create a new file in a Linux environment, you have two options:
1. Using `touch`:
- The `touch` command creates a new, empty file.
- The basic syntax is:
```
touch
```
- Replace `` with the desired name for your file.
- Remember that most Linux filesystems are case-sensitive, so ensure that the filename is spelled exactly as you want it.
2. Using `mkdir` (for directories):
- The `mkdir` command creates a new directory (folder).
- If you want to create a new file within a specific directory, you can first create the directory using `mkdir` and then create the file inside it.
- The basic syntax for creating a directory is:
```
mkdir
```
- Replace `` with the desired name for your directory.
- After creating the directory, you can use `touch` to create files inside it.
Remember that `touch` is specifically for creating files, while `mkdir` is for creating directories. Choose the appropriate command based on your needs
For example:
- To create a new file named "mytext.txt":
```
touch mytext.txt
```
- To create a new directory named "mydir" and then create a file inside it:
```
mkdir mydir
touch mydir/myfile.txt
```
hope it helps
Thanks for the explanation and your time Raghav
Hello Raghav. Do you have any tutorial on merge and rebase. Please help, these both are very confusing to me.
Hi Mukesh, I will try to do a session on this.
@@RaghavPal thank you :) please do for sure....this is a must know for me...thanks again.
Nice videos Raghav....can we connect database tools like SQL_Developer with GIT
Thanks Pradeep for liking the videos. Yes, we can connect Git with SQL developer. This article may be helpful : galobalda.wordpress.com/2014/04/09/sql-developers-interface-for-git-interacting-with-a-github-repository-part-1/
Can you please show the push command that how to use it in git. please
Hi Venkatesh, push command is covered in the session - th-cam.com/play/PLhW3qG5bs-L8OlICbNX9u4MZ3rAt5c5GG.html
HI Raghav,
Can you please the PPT (docker,git) in your github so that it will be very helpful for us.
*share
Hi Kailash, do not have them handy now
i pushed the bracnjh master and it does not update on github like the merge on my local machine why?
There could be multiple reasons why the branch didn't update on GitHub after pushing the changes. Here are a few things you can check:
Check if you pushed the changes to the correct repository and branch.
Ensure that you have the appropriate permissions to push to the repository.
Verify that your internet connection is stable and there were no errors during the push.
Check if there are any conflicts between your local branch and the remote branch on GitHub. If there are any conflicts, you'll need to resolve them before the changes can be merged.
If you have checked all of the above and the issue persists, you can try force pushing the changes to the remote repository. However, this should only be done as a last resort since it can potentially overwrite other changes in the repository
you are on a mac i am on a windows machine how do i create a file at the cli touch doesnt work here ok? Lisa thxz
Hi
On a Windows machine, you can create a new file using the "type nul > filename" command in the Command Prompt or PowerShell.
Here's an example:
Open Command Prompt or PowerShell.
Navigate to the directory where you want to create the file using the "cd" command.
Type "type nul > filename.txt" and press Enter, replacing "filename" with the name you want to give the file and ".txt" with the extension you want to use.
This will create a new empty file with the specified name and extension in the current directory
------------------------------------------
Another option is to install git bash on your windows system. using git bash command line, you will be able to run mac/linux commands
To install Git Bash on Windows, you can follow these steps:
Go to the Git for Windows download page: gitforwindows.org/
Click the "Download" button to download the Git for Windows installer.
Run the installer and follow the prompts to install Git Bash on your system.
Once the installation is complete, you can launch Git Bash by searching for "Git Bash" in the Windows Start menu.
Alternatively, if you prefer to use a package manager to install Git Bash, you can use Chocolatey:
Install Chocolatey by following the instructions on their website: chocolatey.org/install
Open a command prompt or PowerShell window as an administrator.
Type the following command and press Enter to install Git Bash: choco install git
Wait for the installation to complete, and then you can launch Git Bash by searching for "Git Bash" in the Windows Start menu.
thank you i apprecite it i will try --Lisa--
I want to keep the a branch permanently, it is possible?
Hi Subodh, what do you mean by that. The branch remains unless you delete it.
Hi Are you taking any online classes for Ansible, kubernets chef , aws pls let me know
Hi Dasi, not currently, may do it in coming 2 months
hello why do i have enter my passowrd and username each time? its so diffuct to paste the passowrd it doesnt always paste it--can you know how to automate it so we are alrwedy reconized as looged in? Lisa
will need more details. also pls refer the time in video this is related to
Good Tutorial
Thanks for watching Sharat
1. is it possible that that from my current branch I want to push to remote master repo instead of pushing to remote branch. I am in branch 1 and using this cmd "git push origin master".
Also, from master(local) to master(remote), how the merge conflict works? I donot see any notification for Create Pull and Merge request
Hi Rajeev, you will have to pull, push with branches as per the concepts.
This link will help on how to handle merge conflicts stackoverflow.com/questions/161813/how-to-resolve-merge-conflicts-in-git
hello Ragav...when i am pushing my project (console application of .net) on github..its show me timeout ..please suggest what should i do and i can push folder vise..?
do you get any errors in logs. Are you pushing large files.
You can Increase the Git buffer size to the largest individual file size of your repo:
git config --global http.postBuffer 157286400
Thanks ...
You're welcome Biswajit
Raghav, info that you delivered was totally worth it but a got an issue in the last 2 minutes.
I am using windows 7 (32 bit), error says; master->master (fetch first).
error: failed to push some refs to 'github......'
Please help me short out this issue.
Hi Sushant, looks like there were some new commits and you will have to pull first before pushing. You may also have to do a rebase but do with caution. This can help stackoverflow.com/questions/24114676/git-error-failed-to-push-some-refs-to-remote
Amazing
Thanks Abdul
How to merge two branches of different repositories?
I will check and plan to do a session on this.
can i merge branch with login page ? and how please explani
branch with login page? i did not exactly understand. You can merge any branch with other branch like master.
What if we do not do merge?
The changes will not come to the parent or master branch
Hi , I got this error while putting git push -u origin branch1 . before it i was facing key gen issue & i resolved it but now again facing this branch pushing issue . please help me on this .
git push -u origin branch1
error: src refspec branch1 does not match any
error: failed to push some refs to 'my repo link '
Hi Prasanna, did you commit before pushing.
You need to do git add & git commit before pushing.
stackoverflow.com/questions/4181861/src-refspec-master-does-not-match-any-when-pushing-commits-in-git
Raghav - your videos are awesome, though for the life of me I cannot figure out the following error when it comes to checking out a branch: `error: pathspec 'foo' did not match any file(s) known to git.` I've been on stackoverflow, git-scm, github and googled it a million times. When I run `git branch -r` however, I see both the master branch and my foo branch: `origin/foo` and `origin/master`. I'd love you forever if you have any input or can direct me to a solution! Thanks in advance
Hi, glad you liked it. Did you try to do git fetch and git checkout before checking out branch
Hi Raghav, Thanks for your video, I have tried above commands in my machine. While running git push -u origin branch-name, I am getting fatal: protocol 'https' is not supported this error. How to resolve this. Thanks (I am using windows)
Hi Arun, pls re-check your repo url.
@@RaghavPal ya Raghav.... git remote add origin was not helped for me.. I tried with git remote set-url command.. Its works as expected
Glad to know this Arun
sir i want to know that,I don’t have any idea about coding And I did MCA,so Am i able to become a devops engg??
Yes you can, You can start now, learn what all is needed. Can take help from here - automationstepbystep.com/
why I could not git push after I successfully typed git merge new_branch there, also the delete branch both 2 lines commands doesn't work in my laptop, could anyone let me know why, thx
Hi Quincy, pls see if this helps - stackoverflow.com/questions/13597494/git-merge-and-push
C:\Users\Main\Desktop
eact\test_repo2>git push -u origin MyNewBranch
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
C:\Users\Main\Desktop
eact\test_repo2>--did you fforget previous steps? it doesnt work Lisa
It seems like Git is not able to find the remote repository called 'origin'. Here are a few things you can check:
Make sure that you have created a remote repository called 'origin' on a Git hosting service like GitHub, GitLab, or Bitbucket.
Check if you have added the remote repository to your local Git repository. You can do this by running the following command:
git remote -v
This will show you a list of remote repositories that your local Git repository is connected to. Make sure that 'origin' is listed there.
If 'origin' is not listed when you run the git remote -v command, you can add it using the following command:
git remote add origin
Replace with the URL of your remote repository.
Once you have added the remote repository, you can try pushing your branch again using the command:
git push -u origin MyNewBranch
Make sure to replace 'MyNewBranch' with the name of your branch.
Your video and audio explanation is not in sync at end part. But thanks for the video anyway.
thanks for liking.
I did review it again, did not find anything out of sync. Hope this is fine.
May i knw what is solution for below
Error while pushing to git hub
----------------------------------------------
$ git push -u origin branchnew
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
hi Sunil, Check this
stackoverflow.com/questions/12940626/github-error-message-permission-denied-publickey
stackoverflow.com/questions/38556096/github-permission-denied-publickey-fatal-could-not-read-from-remote-reposit
hey raghav, how can i create a branch in existing repo.?
Hi Tushar, you can do as shown in the video. What issue did you face.
hey raghav, i already have 7 existing repo. i am unable to create branch in a particular repo. and 2nd que. is when we add empty directory in a branch why do we need to create .gitignore file? what is the meaning of .?
Hi Tushar, in .gitignore file we generally give the items that we do not want to go to the repo. For e.g. if you have a project and it has a folder that contains images in .png ext. And you do not want this to go to the repo as it will increase the repo size, you can give *.png in .gitignore file.
thanks raghav
This branch is 2 commits ahead, 2 commits behind main. ----this is what it says in my master and MyNewBranch--how is this possible? on my local it says main IS master --i dont unberstand ok Lisa
It's possible to have the message "This branch is 2 commits ahead, 2 commits behind main" if you have made changes in both the master and MyNewBranch branches, but haven't merged those changes to the main branch yet.
When you create a new branch from an existing branch (in your case, you created MyNewBranch from main), the new branch will initially have the same content as the original branch. Any changes you make in the new branch won't automatically be reflected in the original branch until you merge the changes.
If you made changes in both the master and MyNewBranch branches, those changes are independent of each other until you merge them into the main branch. So, if you switch to the master branch and see the message "This branch is 2 commits ahead, 2 commits behind main," it means that the master branch has two commits that haven't been merged into the main branch, and two commits from the main branch that haven't been merged into the master branch.
To resolve this, you can merge the changes from both branches into the main branch so that all the changes are in one place
@@RaghavPal thank you i will check
error: pathspec 'master' did not match any file(s) known to git I am getting this error whenever I use the git checkout master.. Pls help😞😞
Hi Varsha, pls check this discussion stackoverflow.com/questions/5989592/git-cannot-checkout-branch-error-pathspec-did-not-match-any-files-kn
@@RaghavPal No sir, in my gitbash while creating a repo master branch was not added automatically..
so in another webpage of stackoverflow someone said... "master is just the name of a branch, there's nothing magic about it except it's created by default when a new repository is created.
You can add it back with git checkout -b master."..
so I did this and it worked but is it true that master branch is not so important?
Hi Varsha, as said, master is just a branch, just that it gets created at 1st, you can rename it too
@@RaghavPal ok sir, thank you
PS C:\Users\Main\Desktop
eact\test_repo2> git checkout master Already on 'master'
Your branch is up to date with 'origin/master'.
PS C:\Users\Main\Desktop
eact\test_repo2>
--i am really more consfused i tried to create a main bracnh which it did but whn i switch to master it says its already the master --how come in github main is not merged whaterver ok whatebv
It seems like you have created a new branch called "main" locally but haven't pushed it to the remote repository on GitHub. Therefore, on GitHub, the default branch is still "master".
When you switched to the "master" branch, Git is telling you that you are already on the latest version of the "master" branch that is in the remote repository.
To merge your changes from the "MyNewBranch" branch into the "master" branch, you need to:
Make sure you are on the "master" branch locally: git checkout master
Merge the changes from "MyNewBranch" into "master": git merge MyNewBranch
Push the changes to the remote repository on GitHub: git push origin master
After these steps, the changes from "MyNewBranch" should be merged into the "master" branch both locally and on the remote repository.
ok i will check
Hi Raghav, great tutorial. All good. However on my git commands :
1.-git push -u origin master and
2.git push origin --delete My NewBranch
Authentication with username and Password are still required
Note: I have configured credentials with commands
a) git config --global user.email "yourGitHub@email.com"
b)git config --global user.name "yourGitHubusername"
Plus am receiving an email : Basic authentication using a password to Git is deprecated and will soon no longer work.
Hi Jim, I will update this with a new session
totally confuised why is there a main? there is no main on my local machine--i do not underatnd-- i cannot push to main cuz there is no main on my computer very lost whatever Lisa--its 2023 and its so confusng to fiund up to date lessons theey are all mixed up in versions
have replied on your earlier comment
Hi Raghav, for merging master and MyNewBranch i am getting this error ! [rejected] master -> master (fetch first)
error: failed to push some refs to 'github.com/rajeshgithu/Repo2.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details. Please suggest me the solution.
Hi Rajesh, You can fetch pull master first and then do the merge
@@RaghavPal Ok Raghav, Let I do as per your instructions. Thanks.
Hi Raghav, Thanks for Tutorial. You explain in very simple way I understand all git commands properly.
Happy to know that Vishal
awesome explanation
Thanks Neha