<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>learn Git Archives - NeuralLantern.com</title>
	<atom:link href="https://www.NeuralLantern.com/tag/learn-git/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.NeuralLantern.com/tag/learn-git/</link>
	<description></description>
	<lastBuildDate>Sun, 25 May 2025 07:57:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.NeuralLantern.com/wp-content/uploads/2025/04/cropped-2025-04-04-Lantern-03-32x32.png</url>
	<title>learn Git Archives - NeuralLantern.com</title>
	<link>https://www.NeuralLantern.com/tag/learn-git/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Git Basics Tutorial: Learn Version Control, Commits &#038; Branches for Beginners</title>
		<link>https://www.NeuralLantern.com/git-basics-tutorial-learn-version-control-commits-branches-for-beginners/</link>
					<comments>https://www.NeuralLantern.com/git-basics-tutorial-learn-version-control-commits-branches-for-beginners/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Mon, 12 May 2025 09:07:04 +0000</pubDate>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[avoid merge conflicts]]></category>
		<category><![CDATA[coding tutorial]]></category>
		<category><![CDATA[Git basics]]></category>
		<category><![CDATA[Git branches]]></category>
		<category><![CDATA[Git clone]]></category>
		<category><![CDATA[Git collaboration]]></category>
		<category><![CDATA[Git commits]]></category>
		<category><![CDATA[Git for beginners]]></category>
		<category><![CDATA[Git pull]]></category>
		<category><![CDATA[Git push]]></category>
		<category><![CDATA[Git tutorial]]></category>
		<category><![CDATA[learn Git]]></category>
		<category><![CDATA[programming basics]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[version control]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=103</guid>

					<description><![CDATA[<p>Learn Git basics in this fun tutorial! Master version control, commits, branches &#038; collaboration for coding. #GitTutorial</p>
<p>The post <a href="https://www.NeuralLantern.com/git-basics-tutorial-learn-version-control-commits-branches-for-beginners/">Git Basics Tutorial: Learn Version Control, Commits &amp; Branches for Beginners</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Git Basics Tutorial: Learn Version Control, Commits &amp; Branches for Beginners" width="1380" height="776" src="https://www.youtube.com/embed/L-HDXipyEcM?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>Hey there, coders! Want to master Git? This fun, beginner-friendly tutorial covers all the basics: what Git is, how to track changes, commit code, create branches, push to remotes, and collaborate with others. Whether you&#8217;re coding solo or with a team, Git&#8217;s got your back. Avoid losing code, recover old versions, and learn pro tips to dodge merge conflicts. Subscribe for more coding tutorials, and let’s make version control a breeze! #GitBasics #LearnToCode #ProgrammingTutorials</p>



<p>Introduction to Git 00:00:00<br>What is Git 00:00:07<br>Git for tracking changes 00:00:18<br>Git for non-code documents 00:00:24<br>Why use Git 00:00:45<br>Code versioning benefits 00:00:50<br>Recovering deleted code 00:01:15<br>Collaboration with Git 00:02:35<br>Git repository basics 00:04:33<br>Installing Git 00:04:44<br>Creating a Git repository 00:05:08<br>Using git status 00:06:36<br>Adding files to Git 00:07:51<br>Committing changes 00:08:18<br>Checking Git log 00:11:21<br>Viewing changes with git diff 00:12:21<br>Pushing to remote 00:19:44<br>Cloning a repository 00:17:01<br>Branching in Git 00:23:27<br>Merging branches 00:25:21<br>Tagging releases 00:16:00<br>Pulling changes 00:26:55<br>Branching strategies 00:29:55<br>Avoiding merge conflicts 00:32:52<br>Backup and fresh clone tip 00:34:00<br>Conclusion and call to action 00:35:00</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>
</ul>



<p>Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>Hey there, I&#8217;d like to talk to you today about the basics of Git and what is Git.</p>



<p>Git is an awesome system that you can use to track changes to all your code as you write</p>



<p>programs and work on things. And in fact, you can use Git for tracking changes to a wide variety of</p>



<p>documents, not just code only. There&#8217;s a special tool that I used a while back where I could track</p>



<p>used a while back where I could track changes to just regular office documents.</p>



<p>But if you&#8217;re writing text files of some sort or even like, I don&#8217;t know, making SVG graphics</p>



<p>files or something like that, you can track changes to all sorts of stuff. Okay, so it&#8217;s</p>



<p>mostly for coding. So what is Git and why would you want to use Git? Okay, so we talked about</p>



<p>Git being a code versioning system. It will track your changes. Imagine this.</p>



<p>Imagine you&#8217;re writing code and you spend all day, maybe like all month writing a really,</p>



<p>really good algorithm or a really good function or something like that.</p>



<p>And then maybe a year later, you haven&#8217;t been using it.</p>



<p>And you kind of think to yourself, you know, whatever happened to that giant function that</p>



<p>I wrote, that was really good.</p>



<p>And then you realize, oh no, I accidentally, I think I deleted it like several months ago</p>



<p>because I thought I didn&#8217;t need it anymore.</p>



<p>I didn&#8217;t need it anymore.</p>



<p>And now I&#8217;ve changed my mind.</p>



<p>I wish I had that back.</p>



<p>But then by then it&#8217;s too late because the code is gone and maybe you don&#8217;t have a backup</p>



<p>or maybe your backup is just, you know, only a few snapshots deep or whatever.</p>



<p>And so you&#8217;re kind of screwed, right?</p>



<p>So one way that Git can help you is Git lets you look back in time to the state of your</p>



<p>code at any other previous point.</p>



<p>Like every time you make significant progress with your code, you log it in Gits database.</p>



<p>You can just look back in time.</p>



<p>You can look back to see what your code was three years ago.</p>



<p>It&#8217;s awesome.</p>



<p>You can also, you know, revert changes.</p>



<p>You can sort of like branch your code off in two different directions.</p>



<p>Maybe here you&#8217;re just going to be working on bugs and on another branch, you&#8217;re adding</p>



<p>one feature that you think might be a good idea.</p>



<p>a really good idea you could merge that branch into the main branch or if you think that feature</p>



<p>is and is going to be trash and it sucks and you wish you never did it you can just delete that</p>



<p>branch and it doesn&#8217;t affect your main code branch it&#8217;s really cool it&#8217;s also a good tool</p>



<p>for collaboration because multiple people can can push to the git database and they can get</p>



<p>each other&#8217;s changes it&#8217;s kind of a way also to cloudify your code you know like if i&#8217;m writing</p>



<p>writing a program, I can commit some changes and I can push some changes to the cloud.</p>



<p>And then my colleague can pull my changes and they get everything that I just worked on.</p>



<p>And then they can commit some more changes and push it back up to the cloud.</p>



<p>Then I can pull it.</p>



<p>And so we&#8217;re sort of like collaborating and in a way where every single change is logged,</p>



<p>your boss can look at, or you, you know, you can look at all the logs in your commit,</p>



<p>in your git commit database and see who changed what you can see what lines were changed when</p>



<p>when they were changes you can see who introduced a bug there&#8217;s a function in</p>



<p>git that is called git blame where you can look at a source code file and you</p>



<p>can see who is responsible for every single line you can bookmark states of</p>



<p>your code you can do so much it&#8217;s wonderful but anyway I just want to</p>



<p>touch on the basics today I hope I&#8217;ve kind of convinced you that git is a</p>



<p>little bit of a good idea I used to just sort of code and then you know do copy</p>



<p>paste as my backup copy and it was okay but when I started using git even by</p>



<p>started using git even by myself without collaborating um it was tremendously valuable</p>



<p>there were many times when i wanted to look back at a previous state of code and git let me do it</p>



<p>many times when i wanted to revert some mistake that i made and git let me do it</p>



<p>okay so you see my terminal here maybe maybe i should reduce the transparency just a little bit</p>



<p>to like maybe like 85 opacity.</p>



<p>That&#8217;s a little bit better.</p>



<p>Okay, so I&#8217;m gonna go into a documents folder.</p>



<p>I&#8217;m gonna go into a temporary folder</p>



<p>and I&#8217;m gonna remove everything that is, whoops.</p>



<p>Okay, that was just something I was working on earlier.</p>



<p>Okay, so I&#8217;m in a folder.</p>



<p>So what is a Git repository?</p>



<p>Actually a Git repository is just a folder</p>



<p>with some extra information inside of it.</p>



<p>Let me see, I don&#8217;t remember if I installed Git on this machine.</p>



<p>I did.</p>



<p>Okay, if you don&#8217;t have Git, you can get it pretty easily with sudo apt install git.</p>



<p>Or if you&#8217;re on Windows or some other operating system, you can just go to Git&#8217;s website.</p>



<p>It&#8217;s git-sem.com or something like that.</p>



<p>You can just find the installer and just get it in there.</p>



<p>But, so let&#8217;s say, let&#8217;s say I want to make a repository.</p>



<p>directory my repository okay so I&#8217;ve got like an empty folder I&#8217;m going to go inside of it</p>



<p>and this is just a folder it&#8217;s not a repo yet I can convert this folder into a repository by</p>



<p>just using the command git init oh gosh here&#8217;s like a message oh you got to choose what branch</p>



<p>you want I think it&#8217;s actually okay at this point I think they&#8217;ll choose one for me when you see</p>



<p>this you can read them and obey them but they&#8217;re not necessarily mission critical while we&#8217;re just</p>



<p>learning so notice how when i list the directory it&#8217;s no longer empty there&#8217;s a there&#8217;s a git</p>



<p>folder inside of there so if i go inside of the git folder i mean this is really not so much for</p>



<p>humans you can kind of do configuration stuff in here but um this is really gets database of</p>



<p>everything it knows about your code you know when you change stuff what&#8217;s the configuration</p>



<p>So if you actually remove this folder, I&#8217;m going to remove the Git folder.</p>



<p>That&#8217;s all it takes.</p>



<p>Now this folder is just a regular folder.</p>



<p>It&#8217;s no longer a Git repository.</p>



<p>So you probably don&#8217;t want to do that once you&#8217;ve initialized it,</p>



<p>but I&#8217;m going to reinitialize this again.</p>



<p>If I had a bunch of history inside that folder,</p>



<p>then it would have been gone already.</p>



<p>But we&#8217;re just learning.</p>



<p>This is just an empty repository.</p>



<p>So I have a Git repository here.</p>



<p>here. First thing I want to do is try to figure out what Git thinks about the repository. So I&#8217;m</p>



<p>going to use the command git status. Whenever you&#8217;re not sure of what&#8217;s going on, if you think</p>



<p>you need to commit something or push something or pull something or whatever, it&#8217;s probably a good</p>



<p>idea to use git status. I use it all the time. Git status and then git will tell you what to do.</p>



<p>It&#8217;s basically telling you that you haven&#8217;t done anything at this point. So that&#8217;s okay.</p>



<p>a readme file in markdown, my, oops, my project.</p>



<p>You don&#8217;t really need to know about markdown to use Git,</p>



<p>although the two kind of go hand in hand on GitHub.</p>



<p>But I&#8217;m just going to say, well, here&#8217;s my project.</p>



<p>This is my super cool project.</p>



<p>Okay, so pretend this is a program, a complicated program.</p>



<p>So I&#8217;m saving it.</p>



<p>We can verify that I actually like put something into that file.</p>



<p>So now I&#8217;m going to ask Git, you know,</p>



<p>you know, what do you think about the state of this repository?</p>



<p>So I&#8217;m going to say git status.</p>



<p>Git is telling me now that we&#8217;re on the master branch</p>



<p>and there are no commits yet.</p>



<p>And I have an untracked file.</p>



<p>This means that the readme file is not considered part of the git repository.</p>



<p>It&#8217;s just sitting in the directory tree.</p>



<p>So I want to add that into my repository so I can start tracking changes.</p>



<p>So I&#8217;m going to say git add and then the name of the file.</p>



<p>What have I done?</p>



<p>Okay, here we go.</p>



<p>What have I done? Okay, here we go.</p>



<p>That&#8217;s not how you spell add.</p>



<p>So now that I&#8217;ve done git add, I can say git status one more time to see what</p>



<p>Git thinks about the state of my repository.</p>



<p>Git says, well, you definitely use the add in order to put the changes on a stage.</p>



<p>Git likes to bunch up changes on a stage before you actually commit things to the</p>



<p>database. The reason for that is maybe</p>



<p>maybe you spend an hour doing a bunch of work in a bunch of different areas of your</p>



<p>different areas of your program, but maybe there&#8217;s only like a few files over here that</p>



<p>are part of a logical change.</p>



<p>Like this is feature a that I was fixing, but you also changed a bunch of other files</p>



<p>that were related to something else like feature B that I was fixing.</p>



<p>It doesn&#8217;t really make sense to take all of those changes and make them one commit because</p>



<p>you want a nice clean commit log that shows exactly what you were working on.</p>



<p>And it makes sense.</p>



<p>you just worked on a bunch of different files,</p>



<p>you can add all the feature A files to the stage first</p>



<p>and then commit that as one change</p>



<p>and then go over to the feature B files</p>



<p>and add those to the stage</p>



<p>and then commit that as a second change.</p>



<p>So it&#8217;s kind of a way to get you out of the mess</p>



<p>you&#8217;ve put yourself in</p>



<p>if you&#8217;ve just been working too long without committing.</p>



<p>You should really do a git commit</p>



<p>every time you make significant progress.</p>



<p>Like, I mean, it depends on where you&#8217;re working</p>



<p>where you&#8217;re working or who you&#8217;re talking to. You definitely don&#8217;t want to commit every line</p>



<p>that you change. You definitely don&#8217;t want to work for like a month and then do one commit at the end</p>



<p>of the month. The sweet spot is somewhere in between. Your boss will probably tell you what</p>



<p>to do. For me personally, every time I fix something, I&#8217;ll make a commit. One thing,</p>



<p>you know, I made significant progress in my program by adding a new feature. One little</p>



<p>feature, I&#8217;m going to commit it. Some people like to do commits at least once a day so that if</p>



<p>to do commits at least once a day so that if they&#8217;re working on a huge new feature, then</p>



<p>they&#8217;ll do like one commit a day. And then they&#8217;ll sort of like call those several commits</p>



<p>part of like a new feature. It&#8217;s up to you. But at this point, we just have the one file</p>



<p>that we made up on the stage. It&#8217;s ready to be committed. We used git status. So git</p>



<p>is just telling us how to commit it. It&#8217;s like, oh no, it&#8217;s not telling us. It&#8217;s just</p>



<p>saying we need to commit it. It&#8217;s not saying how. If you want to unstage it, then here&#8217;s</p>



<p>commit command is just git commit now it&#8217;s going to ask me for a commit message this is what you</p>



<p>will see in the log so don&#8217;t just put work don&#8217;t put change don&#8217;t put something that doesn&#8217;t</p>



<p>describe what you did you should describe exactly what you did so so what i&#8217;m going to do is for</p>



<p>the commit message i&#8217;m going to just sort of say what i did you can imagine writing something like</p>



<p>i created the readme file it should always definitely describe exactly what you did</p>



<p>um but it seems like a lot of people use uh i guess grammar and and and terseness</p>



<p>just to make the commit message sound like they told somebody to do something so create the readme</p>



<p>file instead of i created the readme file create the readme file so i&#8217;m just going to make that my</p>



<p>commit message save the buffer and then uh now that i&#8217;ve committed the changes i have to ask</p>



<p>you know git status what did i do you know what&#8217;s the state of the repository it is now saying that</p>



<p>that the repo is clean, everything looks pretty good.</p>



<p>So that means my changes are recorded in the Git database.</p>



<p>I can now actually use a command called Git log to see what changes have been recorded.</p>



<p>Notice how there&#8217;s only one change.</p>



<p>It&#8217;s just, you know, my name here, when it was changed and then what I did.</p>



<p>There&#8217;s a hash here.</p>



<p>This little hexadecimal string is called a hash.</p>



<p>to show me what happened in any specific commit by saying git show and then I give it a hash</p>



<p>and it&#8217;ll tell me exactly what files were created or changed or deleted or whatever</p>



<p>and there it is right there this will get more interesting in a second let&#8217;s make a change</p>



<p>I&#8217;m going to say edit the readme file and we say this is my super cool project this is my first</p>



<p>So I&#8217;m going to say git status to find out what&#8217;s going on.</p>



<p>Git says, oh, you made a change there.</p>



<p>It&#8217;s not saying that this file is not part of the database.</p>



<p>It&#8217;s just saying that we made changes.</p>



<p>I want to see the changes that it&#8217;s talking about.</p>



<p>I could say git diff.</p>



<p>And it&#8217;s telling me that I added this line.</p>



<p>My dog is growling at me.</p>



<p>about peeing oh my gosh hang on</p>



<p>so i&#8217;ll let him back in he&#8217;ll try to lie to me and he&#8217;ll try to get free treats</p>



<p>okay so uh we can use the command git diff to see what our changes are we can also say</p>



<p>git diff whoops git diff and then name a file and it&#8217;ll tell us what&#8217;s changed in that one file</p>



<p>second line so great back to get status it&#8217;s saying we need to stage that change</p>



<p>so I&#8217;m just gonna say get add and then the name of the file get status again</p>



<p>so that we know what&#8217;s up it&#8217;s saying all right well you just need to commit</p>



<p>the changes on your stage if you&#8217;d like to so yeah sure I&#8217;m gonna say get commit</p>



<p>and I&#8217;m gonna say you know changed the readme or something okay get status</p>



<p>So now if we do git log, there&#8217;s two entries.</p>



<p>Imagine that this happens every single time</p>



<p>somebody makes a significant change.</p>



<p>You know, it&#8217;s just like it goes in the log.</p>



<p>You can figure out who changed what.</p>



<p>Watch this.</p>



<p>Let&#8217;s do cat readme so we can see the readme.</p>



<p>Notice how it&#8217;s got the second line at the end.</p>



<p>I could also go back in time</p>



<p>and see what the state of my project was</p>



<p>was after that first commit so i could i&#8217;m going to copy paste that first commit and i&#8217;m going to</p>



<p>say git checkout and the commit hash it&#8217;s now telling me something hey by the way now you&#8217;re</p>



<p>looking back in time you should not change anything you&#8217;re on a detached head if you&#8217;re</p>



<p>ever unsure of where you&#8217;re actually at in git you should do git branch all and it&#8217;ll just sort</p>



<p>of show you where you&#8217;re at i was on the master branch now i&#8217;m on a detached head but notice if i</p>



<p>But notice if I spill the contents of the README file.</p>



<p>Hang on, what did I do wrong?</p>



<p>Change the README.</p>



<p>Oh, sorry, it&#8217;s in reverse order.</p>



<p>I always forget that.</p>



<p>I copied the wrong hash.</p>



<p>So let me check out the first commit that I made.</p>



<p>So I&#8217;m going to say git checkout the first commit hash.</p>



<p>Okay, now I&#8217;m going to concatenate the,</p>



<p>or I&#8217;m going to spill the contents of the README.</p>



<p>Notice how the readme looks like it did when we first made it.</p>



<p>So we&#8217;ve gone back in time.</p>



<p>Think of how useful this could be if this was a huge, big project with a bunch of files</p>



<p>and a lot of lines per file.</p>



<p>So once again, we&#8217;ll do git, actually let&#8217;s do git status.</p>



<p>Status is reminding me that we&#8217;re on its attached head.</p>



<p>and we can also use git branch to see that we&#8217;re still in the detached head you want to get back</p>



<p>onto the master branch or whatever branch you&#8217;re working with before you continue working so we&#8217;ll</p>



<p>status and you can see that we&#8217;re on the master branch.</p>



<p>Then we can say get branch all.</p>



<p>And there we go. Maybe we want to bookmark this.</p>



<p>Maybe we want to remember, oh, this is a perfect state of our of our code.</p>



<p>Maybe this is version one point.</p>



<p>We can do get tag version one point.</p>



<p>Oh, and now we have a bookmark forever.</p>



<p>How can we find the bookmarks?</p>



<p>Well, we can say get tag just by itself, and it&#8217;ll give us a list of our bookmarks.</p>



<p>When we push this to a remote server, the server will be able to show it like</p>



<p>remote server, their server will be able to show it like GitHub or GitLab or whatever.</p>



<p>And then later we can do something like, you know, get checkout and then just check out the</p>



<p>name of a tag. So it&#8217;s kind of the same thing as checking out a commit hash, but it&#8217;s like</p>



<p>a bookmark that&#8217;s a little bit easier to remember. So let&#8217;s look at remotes for a second,</p>



<p>because right now we&#8217;re not pushing code anymore. We&#8217;re just remembering what we changed in our</p>



<p>Okay, so I&#8217;m inside my repository.</p>



<p>And now I&#8217;m going to go up a level on this right pane,</p>



<p>and I&#8217;m going to make a new directory.</p>



<p>But I&#8217;d like to clone the original repository.</p>



<p>Imagine that this repository, it&#8217;s a folder to us,</p>



<p>but it could be for all we know, sitting on a remote server</p>



<p>and accessed with a special URL.</p>



<p>So you can go to like GitHub or somebody&#8217;s server,</p>



<p>and you can copy their get URL for their repository.</p>



<p>repository. Over here in our local file system, we could clone the original repository.</p>



<p>Usually you would have to copy paste like a big get URL, SSH URL or HTTPS URL or whatever.</p>



<p>But you can even do this locally so I can tell get I would like to clone this local repository</p>



<p>denoted by this folder name. And I would like to call it my clone or something. So I&#8217;m gonna say</p>



<p>So I&#8217;m going to say get clone repository my clone.</p>



<p>It says cloning and done.</p>



<p>Now we have two folders.</p>



<p>And if we go inside of the my clone repository,</p>



<p>we should have the same state of code that we just cloned.</p>



<p>So that makes sense.</p>



<p>Now think about collaboration.</p>



<p>We can change our code from the clone.</p>



<p>And as long as the clone has permission to push back up to the remote,</p>



<p>back up to the remote then it actually would work.</p>



<p>So let&#8217;s edit the README file real fast.</p>



<p>So I&#8217;m going to go nano README and I&#8217;m going to say this change was made by the clone.</p>



<p>Okay, so I did that.</p>



<p>And actually just to make things interesting, I&#8217;m going to change my git identity only inside</p>



<p>of this clone.</p>



<p>You can do that in git.</p>



<p>config and you say something like user.name, you know, you can put your name here, your email,</p>



<p>whatever, for like user.email. There&#8217;s this thing that you usually do where you say get config</p>



<p>global. And that means you&#8217;re changing configuration that is account wide. So like</p>



<p>your entire account on this machine is going to be changed when you use that global flag.</p>



<p>But if I don&#8217;t use the global flag, it&#8217;s just changing my configuration for only this one</p>



<p>this one repository so i&#8217;m going to make my name clone dude and make my email</p>



<p>clone dude at laptop or whatever at server so now if i say git status over here it&#8217;s telling me hey</p>



<p>i have like a change i say git diff and it tells me oh look i you know you changed that last line</p>



<p>so i&#8217;m going to add that change to the stage and then i&#8217;m going to commit it and i&#8217;m going to say</p>



<p>I added something to the readme.</p>



<p>Okay.</p>



<p>Git status.</p>



<p>Notice how git status is saying something a little bit extra this time.</p>



<p>Before, we were just in a local file system only.</p>



<p>And now we&#8217;re working inside of a clone.</p>



<p>So this is like, you know, you clone some code from GitHub</p>



<p>or from your friend&#8217;s server or whatever.</p>



<p>And when you do a clone,</p>



<p>it actually automatically links your local repository</p>



<p>repository to the remote repository. By the way, in Git, everything is considered a local copy. So</p>



<p>it&#8217;s not like you&#8217;re working with something different than the server has. You actually</p>



<p>have the entire Git history and all the code and everything that Git has on the remote,</p>



<p>except for maybe some like configurations or something. But when you pull, you&#8217;re just making</p>



<p>you&#8217;re making a copy later we can push our changes to the server and that just makes</p>



<p>the two repositories talk to each other sort of and reconcile changes and make sure that both sides</p>



<p>have the differences i guess so it&#8217;s telling us we need one more step it&#8217;s saying git status and</p>



<p>it says you&#8217;re on the master branch your branch is ahead of origin master by one commit what&#8217;s</p>



<p>origin master you can find out all of your remote connections and get by saying git remote v so when</p>



<p>so when you clone it automatically makes an origin remote it calls it origin and</p>



<p>then it has the URL or in this case just the file path of where the remote is so</p>



<p>it&#8217;s telling you that our remote where we&#8217;re connected to is the my repository</p>



<p>folder that we were at in the left pane so it&#8217;s telling us also if we go back to</p>



<p>just status it&#8217;s telling us that we should use git push to publish my local</p>



<p>my local commits to the remote because at this point we&#8217;re out of sync if uh if somebody else</p>



<p>cloned the remote repository and then made a bunch of changes and then pushed then i would now be</p>



<p>totally out of sync with that new person who cloned and also the remote server and it would</p>



<p>create something called a merge conflict which is like a little bit more advanced than this video</p>



<p>and we&#8217;d have to take steps to resolve it so the smartest thing to do is um well if you&#8217;re</p>



<p>Make sure that everybody is designated a certain file or set of files to work on and you all talk to each other.</p>



<p>Hey, I just pushed some code.</p>



<p>You need to pull.</p>



<p>Hey, I&#8217;m about to push.</p>



<p>Hold off a second.</p>



<p>Hey, I just pushed.</p>



<p>If you&#8217;re working on something, you&#8217;ve got to pull my changes before you do a push.</p>



<p>Always push after you commit so that everybody has the latest copy on the remote so you don&#8217;t cause conflicts with your teammates or whatever.</p>



<p>and always try to do pulls regularly.</p>



<p>Anyway, so I need to push my code.</p>



<p>I&#8217;m going to say git push.</p>



<p>And it&#8217;s saying, oh gosh, what is it saying?</p>



<p>Oh, okay, okay, okay, okay.</p>



<p>This is going to be a special setup that I have to do.</p>



<p>Let me just very quickly revert what I&#8217;m doing here.</p>



<p>I think I have to…</p>



<p>Oh, I know what to do. I can just make it a little trick.</p>



<p>Usually the thing is they don&#8217;t want you to push onto a branch that the remote has currently checked out into the file tree.</p>



<p>But usually remote servers, they don&#8217;t have a branch checked out.</p>



<p>So you won&#8217;t even see the file system on the remote.</p>



<p>It&#8217;ll actually all look like just this.</p>



<p>There&#8217;s a flag called bear that you can use to make that happen.</p>



<p>But I don&#8217;t really want to go through all the steps right now.</p>



<p>So what I&#8217;m going to do is I&#8217;m just going to make another dummy branch and then just kind of sit on it for a while.</p>



<p>dummy branch and then just kind of sit on it for a while.</p>



<p>That way I&#8217;m allowed to push to the master branch.</p>



<p>So I&#8217;m going to say get branch.</p>



<p>This is how you make a new branch.</p>



<p>I&#8217;m going to say dummy or something.</p>



<p>Whoops, got to spell branch, right?</p>



<p>Then get checkout dummy and then get branch all and then get status just to make sure</p>



<p>I&#8217;m now sitting on the dummy branch.</p>



<p>And then this will cure the problem that we had a moment ago where we&#8217;re not</p>



<p>allowed to push to a branch that the remote has checked out.</p>



<p>branch that the remote has checked out so i&#8217;m gonna say git oh wait hang on gotta go back in there</p>



<p>my clone git push okay so now it works uh so keep in mind if you&#8217;re pushing to you know a remote</p>



<p>that has a branch that&#8217;s checked out like it&#8217;s another file system like it&#8217;s a friend&#8217;s computer</p>



<p>you&#8217;re gonna have to worry about this sort of thing but if it&#8217;s a server like github or just</p>



<p>someone who has set them set the repository up properly uh you won&#8217;t have to worry about it so</p>



<p>Forget about that for now.</p>



<p>So I pushed to the remote.</p>



<p>If I do git log over here, there&#8217;s a mix.</p>



<p>It shows, you know, Mike created it and then changed it.</p>



<p>And then the clone dude added something too.</p>



<p>Okay.</p>



<p>So if I say git log, we should now see the history for only the dummy branch.</p>



<p>So that&#8217;s just two things.</p>



<p>And if I say git checkout master, and then I check out and then I look at the log for</p>



<p>I can see all the changes that the other person made.</p>



<p>Pretty cool.</p>



<p>I could also go back into the dummy branch if I wanted to.</p>



<p>I actually used to do this a long time ago before I realized you should do bear repos.</p>



<p>Let&#8217;s see.</p>



<p>Check out dummy.</p>



<p>And then I&#8217;ll say git log just to confirm that the changes aren&#8217;t in there.</p>



<p>So now we have two branches that are kind of diverging a little bit.</p>



<p>the master branch has one more commit than the dummy branch and if we let this go on for far too</p>



<p>long it might be more of a hassle to make the branches merge again but i&#8217;m just going to merge</p>



<p>them right now so i&#8217;m going to say git merge verify that you&#8217;re sitting on the correct branch</p>



<p>that you want to be the destination branch so i&#8217;m sitting on the destination the dummy branch so i&#8217;m</p>



<p>going to say git merge and i&#8217;m going to give it the name of the branch that i want to merge changes</p>



<p>It&#8217;s telling me that something happened.</p>



<p>So if I do get branch again one more time, I&#8217;m still on the dummy branch.</p>



<p>But if I do get log, notice how I have that latest log entry.</p>



<p>Pretty cool.</p>



<p>So now I&#8217;m going to go back onto the master branch because I want to do some work here.</p>



<p>This is a little clumsy.</p>



<p>If we&#8217;re talking about a server client paradigm, just bear with me.</p>



<p>Now I&#8217;m going to make another change.</p>



<p>Hi, Mr. Clone.</p>



<p>clone. Can you read this? So I&#8217;m going to make a change that I want the clone person to see.</p>



<p>Git status, git add, the readme. You could also do git commit dash a, but I kind of don&#8217;t like</p>



<p>to because I&#8217;d like to remind myself that the stage is a good idea. Git commit new readme</p>



<p>okay so I&#8217;m not I don&#8217;t have a remote I am the master so there&#8217;s nowhere to push</p>



<p>but now in the clone I can say git status it doesn&#8217;t yet know that the that the</p>



<p>remote has changes I could do git pull to actually pull all the changes or I</p>



<p>can do git fetch fetch will sort of talk to the remote and pull the changes into</p>



<p>this repository&#8217;s local copy of the remote.</p>



<p>So if we do git branch all, you&#8217;ll notice that we have a master branch here.</p>



<p>So the master branch is my master branch.</p>



<p>And all these other branches here are local copies of the remotes branch.</p>



<p>So we&#8217;re just making lots and lots of copies.</p>



<p>That&#8217;s kind of how git works.</p>



<p>But now that we did a fetch, that talked to the remote, it grabbed changes.</p>



<p>Now Git understands that we&#8217;re actually behind the remote by one commit.</p>



<p>And it&#8217;s telling us, well, you need to use Git pull to pull all the changes.</p>



<p>Usually you kind of don&#8217;t need to do Git fetch.</p>



<p>If you have a remote, you just say Git pull.</p>



<p>You only do Git fetch if you want to kind of see what&#8217;s going on with the remote first before you</p>



<p>actually try to pull all the changes into your branch.</p>



<p>It&#8217;s a more complicated situation.</p>



<p>So if I say Git pull, now inside of my Git log, I have that last change.</p>



<p>that last change that the master gave us.</p>



<p>So this is like a very, very basic workflow for Git</p>



<p>in terms of making changes to your program,</p>



<p>committing the changes, checking out the log,</p>



<p>checking out what was changed,</p>



<p>pushing to a remote and so forth.</p>



<p>The only difference, by the way,</p>



<p>between using a remote that&#8217;s a file system</p>



<p>and using a remote that&#8217;s GitHub</p>



<p>is just what URL you put in clone.</p>



<p>in clone like if i put if i said git clone i put a file path here originally but if i just</p>



<p>put a clone url that github gave me or your friend&#8217;s server gave you right there then it</p>



<p>would work basically the same way it&#8217;s pretty sweet um let&#8217;s see so those are the basics of git</p>



<p>always make sure that you push to the remote so that the server has your changes and if you&#8217;re</p>



<p>using github or another website uh it&#8217;s it&#8217;s usually a really good idea to push and then go</p>



<p>to the website to double check that your changes actually made it.</p>



<p>So we talked about tags and branches.</p>



<p>This video is not going to be for advanced branching strategies,</p>



<p>but there are lots of cool resources you can check out.</p>



<p>Actually, you know what? I&#8217;m going to pull one up. Let&#8217;s see.</p>



<p>I&#8217;m going to edit this out if it ends up being like a really bad search result.</p>



<p>Get branching strategy.</p>



<p>big project with a big team let&#8217;s see there&#8217;s one that I used to love where the heck is it</p>



<p>I think this month no that&#8217;s not the link I remember I should have bookmarked it but there</p>



<p>are lots of different strategies for how and why you would want to use um branches let&#8217;s see one</p>



<p>of these has a good diagram this is it this is not the same web page but I think this website</p>



<p>diagram that I remember.</p>



<p>So we&#8217;ve been on the master branch.</p>



<p>That&#8217;s like the right side here.</p>



<p>You know, this little, these little blue dots.</p>



<p>Imagine that every single time you want to create a new feature,</p>



<p>you just create a branch and you name it after the feature that you&#8217;re creating.</p>



<p>I think I mentioned that before that allows you to sort of keep working on the</p>



<p>master branch independently of the feature that you&#8217;re working on.</p>



<p>And then later when you&#8217;re sure you want to merge the feature into the master</p>



<p>branch, then you just use a get command to make the two branches merge.</p>



<p>command to make the two branches merge.</p>



<p>Or if the feature turns out to be a bad idea, you can just delete the branch.</p>



<p>Usually, at minimum, most people will do something like this.</p>



<p>They&#8217;ll have a development branch.</p>



<p>So here you can see the yellow dots.</p>



<p>That&#8217;s development.</p>



<p>And what they&#8217;ll do is they&#8217;ll make all of their commits to the development branch.</p>



<p>And then only whenever the program is in a really good state, like it&#8217;s sort of presentable,</p>



<p>you can actually release it.</p>



<p>let your friend run the code or whatever, then you&#8217;ll merge the dev branch into the master branch</p>



<p>without deleting the dev branch. So you&#8217;ll merge the dev into master every time the code is in a</p>



<p>really good state. And then you&#8217;ll come back on to dev to continue developing. I think most people</p>



<p>call it develop. Actually, I call it dev for mine. And that way, the master branch usually only ever</p>



<p>is in a state that is good that people could clone from and just compile the program or use the</p>



<p>or use the program or whatever.</p>



<p>And that is in addition to adding tags</p>



<p>whenever you think the master branch is in a state</p>



<p>that you think is like a significant release.</p>



<p>So like version 1.0 or 1.2 or whatever.</p>



<p>So branches for development</p>



<p>where you&#8217;re always there most of the time.</p>



<p>Branches for feature when you&#8217;re kind of experimenting</p>



<p>and trying to figure out</p>



<p>if you&#8217;re going to be able to add something.</p>



<p>Branches for, there&#8217;s a branch for the master</p>



<p>where it&#8217;s like this is the state</p>



<p>that the public should see,</p>



<p>the state that actually works.</p>



<p>actually works. And then, you know, you might do a temporary branch for a hot fix.</p>



<p>And sometimes people will do a new branch for a future release. Like if you&#8217;re going to release</p>



<p>version 2.0, you might make a new branch and call it version 2.0 and then just work on that and</p>



<p>kind of like merge changes from dev in that and just make sure that it&#8217;s all good and it&#8217;s great.</p>



<p>And as soon as you think that the feature branch is perfect for your release, sorry, not</p>



<p>Sorry, not feature branch.</p>



<p>Release branch is great for your release.</p>



<p>Then all at once, you&#8217;ll merge that whole thing into master.</p>



<p>You don&#8217;t have to do it that way.</p>



<p>It doesn&#8217;t have to be that complicated,</p>



<p>but sometimes it can be that complicated.</p>



<p>For me personally, I usually just do a development branch</p>



<p>and a master branch.</p>



<p>And then sometimes when I&#8217;m taking a risk,</p>



<p>I&#8217;ll make a feature branch for the new thing that I&#8217;m trying.</p>



<p>So I just kind of wanted to show you that for branching.</p>



<p>for branching and</p>



<p>we talked about pulling and pushing and cloning</p>



<p>yeah so just uh i guess one more warning to make sure that you don&#8217;t</p>



<p>end up with merge conflicts when you&#8217;re collaborating with other people</p>



<p>or even actually this happens to people who work by themselves and they just</p>



<p>switch computers a lot make sure that when you first sit down</p>



<p>and you&#8217;re about to start coding you always pull</p>



<p>team of people communicate with them and tell them you&#8217;re about to pull tell them you&#8217;re about</p>



<p>to start working on something tell them tell them what you&#8217;re about to start working on unless you</p>



<p>have like a manager who&#8217;s telling you exactly what to work on then it&#8217;s their problem um</p>



<p>and then do your get pull and then work and then every time you make significant progress</p>



<p>do a commit and then tell everybody i&#8217;m about to push and then push and then make sure that you</p>



<p>So if you go on your lunch break, make sure you push before you go on your lunch break.</p>



<p>And when you come back from your lunch break, make sure you pull right away.</p>



<p>Because if you don&#8217;t pull and push enough, you&#8217;re either going to get merge conflicts</p>



<p>on your end or you&#8217;re going to cause other people to get merge conflicts.</p>



<p>And sometimes it takes a lot of time to resolve the merge conflicts.</p>



<p>So you really don&#8217;t want to deal with that.</p>



<p>And then a beginner&#8217;s tip, or I guess like maybe like an easy tip.</p>



<p>I do this actually sometimes.</p>



<p>up totally forgetting to push and pull and you do a lot of code and you kind of like wreck everything</p>



<p>and you don&#8217;t want to deal with a gigantic merge conflict resolution type of situation sometimes</p>



<p>it&#8217;s easier to just copy paste your folder somewhere else rename it remember a git repository</p>



<p>locally it&#8217;s just a folder so you can copy paste it or rename it or whatever you want to do</p>



<p>you just kind of copy paste it somewhere and then perform a fresh clone from the remote</p>



<p>then there&#8217;s not going to be a merge conflict because the fresh clone is going to be directly</p>



<p>from the remote which is not conflicted on its own then you&#8217;ll have your fresh clone and then</p>



<p>you&#8217;ll have your little backup copy of what you just screwed up then you can manually inspect the</p>



<p>difference between the fresh clone and then the thing that you just screwed up or you can just</p>



<p>start copy pasting some of your changes and then do like a commit and then do push and then it</p>



<p>Git Basics tutorial. I hope you learned a little bit of stuff and had a little bit of fun.</p>



<p>I will see you in the next video.</p>



<p>Hey everybody. Thanks for watching this video again from the bottom of my heart. I really</p>



<p>appreciate it. I do hope you did learn something and have some fun. If you could do me a please,</p>



<p>a small little favor, could you please subscribe and follow this channel or these videos or</p>



<p>whatever it is you do on the current social media website that you&#8217;re looking at right now.</p>



<p>It would really mean the world to me and it&#8217;ll help make more videos and grow this community</p>



<p>So we&#8217;ll be able to do more videos longer videos better videos or just I&#8217;ll be able to keep making videos in general</p>



<p>so please do do me a kindness and</p>



<p>And subscribe you know sometimes</p>



<p>I&#8217;m sleeping in the middle of the night and I just wake up because I know somebody subscribed or followed it just wakes me up</p>



<p>And I get filled with joy. That&#8217;s exactly what happens every single time</p>



<p>So you could do it as a nice favor to me or you could you control me if you want to just wake me up in the middle</p>



<p>me if you want to just wake me up in the middle of the night just subscribe and then i&#8217;ll just</p>



<p>wake up i promise that&#8217;s what will happen also uh if you look at the middle of the screen right now</p>



<p>you should see a qr code which you can scan in order to go to the website which i think is also</p>



<p>named somewhere at the bottom of this video and it&#8217;ll take you to my main website where you can</p>



<p>just kind of like see all the videos i published and the services and tutorials and things that i</p>



<p>have a suggestion for uh uh clarifications or errata or just future videos that you want to</p>



<p>see please leave a comment or if you just want to say hey what&#8217;s up what&#8217;s going on you know just</p>



<p>send me a comment whatever i also wake up for those in the middle of the night i get i wake</p>



<p>up in a cold sweat and i&#8217;m like it would really it really mean the world to me i would really</p>



<p>appreciate it so again thank you so much for watching this video and um enjoy the cool music</p>



<p>fade into the darkness which is coming for us all.</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/git-basics-tutorial-learn-version-control-commits-branches-for-beginners/">Git Basics Tutorial: Learn Version Control, Commits &amp; Branches for Beginners</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/git-basics-tutorial-learn-version-control-commits-branches-for-beginners/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
