Committing Changes in Git and Pushing to a GitHub Repository
HTML-код
- Опубликовано: 2 май 2014
- This is video #8 in the Data School series, "Introduction to Git and GitHub." Relevant links, a command list, and the full transcript are below. Playlist: • Version control with G...
== LET'S CONNECT! ==
Blog: www.dataschool.io
Newsletter: www.dataschool.io/subscribe/
Twitter: / justmarkham
GitHub: github.com/justmarkham
== LINKS RELATED TO THIS VIDEO ==
Git quick reference for beginners: www.dataschool.io/git-quick-re...
Tracking, staging, and committing: git-scm.com/book/en/Git-Basics...
Markdown Live Editor: jrmoran.com/playground/markdow...
Mastering Markdown: guides.github.com/features/ma...
== COMMAND LIST ==
create a file: touch [filename]
check the status: git status
track and stage a single file: git add [filename]
track and stage all files: git add .
commit with a message: git commit -m "description of commit"
view the log: git log
push changes: git push [remotename] [branchname]
== TRANSCRIPT ==
In this video, we're going to continue working with the "test-repo" we created previously. Specifically, we're going to edit an existing file, add a new file, commit those changes, and push those changes up to GitHub.
To start, we've already opened up Git Bash and changed our working directory to test-repo. As you might recall, there's just one file in the repo, which is the "README.md" file. We're going to edit that file.
Since it's a Markdown file, you can edit it in any text editor. I've opened the file in Windows Notepad, and am just going to make a simple edit and then save the file.
Let's also create a new Markdown file called "new.md". We're going to use a command called "touch". It's not a Git command, but it's especially handy on Windows since it can be hard to create a file with a non-standard extension. Simply type "touch" and then the name of the file. You can see that it has been created.
The file we created is empty, so let's open it in Notepad.
I've written some Markdown code in this Markdown Live Editor, so that you can see a preview of what it looks like. The Markdown code is on the left, and the rendered version is on the right. I'll link to this tool in the video description.
Anyway, let's copy the Markdown code to the new.md file and save it.
We're back in Git Bash, and are going to run the "git status" command to see the status of our files. It tells us that we've got one tracked file that has been modified, and one untracked file that has been added.
We want to stage both of these files for committing. We use the "git add" command to do this. You could do this one file at a time using "git add" and then the filename. But instead, we're going to use "git add ." which adds both of them at once.
Let's run the status again. We can see that the changes are ready for committing.
To commit, use the "git commit" command. We use the "-m" argument and write a message because every commit should have a descriptive message.
The commit is complete, and we can run "git status" to confirm that there is nothing else to commit. We can also check the log to see that the commit is there.
Everything we've done so far has only affected our local machine. To get our GitHub repo up-to-date, we need to push up our changes.
To push our changes, we use the "git push" command. The specific command is "git push origin master", which means that we want to push the "master" branch to the "origin" remote. Remember that in a previous video, we set up the "origin" remote to refer to our GitHub repository.
Type in your password, and you're done. Refresh GitHub, and you can see that the "README.md" file has been modified, and the "new.md" file has been added. You can also see the commit history.
On my blog, dataschool.io, I've got a Git quick reference guide that I wrote specifically for beginners, containing these and other common commands. I'll link to it in the video description, and hopefully you'll find it to be useful.
This video was incredibly helpful and much more useful than some of the much longer videos I've watched. Thank you!
Thank you, thank you, thank you! Your tutorials are so clear and simple! I have really been struggling to learn how to use Git, and your videos have walked me through the process so seamlessly! I really wish I could give you a million dollars to keep doing what you're doing. I am so grateful!
I've been searching tens of websites on how to push changes to GitHub repo, but most of them were so intricate and incomprehensible. This is the simplest video solution more than I'd expected. Thank you so much!
Hi Kevin, thank you very much for taking the time to document this. Very well done, hugely beneficial, saved me even more hours of trying to figure this out.
Awesome, glad to hear Mark! My goal was always to create the kind of resource that would have helped me out in the beginning... happy to share my lessons learned!
These are awesome videos on GIT, not only are they clear but you explain what is going on and where the changes are made (local or internet) for each command.
Glad it was helpful to you!
Thank you for such a clear and concise explanation about the basics of Git. I began the Coursera course about Data Scientist Tools and I was at a lost with using the commands to complete the first capstone project. I appreciate your videos and I look forward to reading your blog.
Finding your videos really useful for my coursera course. Thank you much for keeping them short and to the point. Looking forward to learning & practicing more of it. Thanks again!
+Shafaq Sarwar You're very welcome! I'm happy to help :)
Thank you so much! This series of videos is incredibly helpful. I don't know what I would have done without them.
jeansinger You are so welcome!
Thank you, Data School for keeping it short and to the point!
You're welcome!
this is by far the best and easiest video I have seen on this and I've watched plenty by now. thanks a million
Wow, thank you so much!
I 'm just yearning for this since 2-3 days and came up with your video and my problem has solved .you made my day .. thank you man :)
You're very welcome!
Thanks Kevin, this video is great! It is short and complete at the same time. Definitely helpful!
Thanks to your videos, I'm not completely bald (I found them before I tore ALL of my hair out in frustration). The transcripts are above and beyond the call of duty, and I'm looking forward to exploring your links. Your work is greatly appreciated!
Your simple and clear video helped me remember the steps on how to use Git. Thanks!
Glad it helped!
Best explanation of all the Github videos seen till now...👌
Glad you think so!
I just started a coding intensive and I used this video as a quick reference to push my assignment's changes to github. Thank you!
Great to hear!
Clear and concise explanations are hard to come by - thank you
You're very welcome!
Thank you very much for such a nice, easy and clean review of committing changes in Git and Pushing to a GitHub Repository. Just viewed it once, repeated all the instructions and was able to commit. Great job!
Great! You are very welcome. I spent a lot of time refining these videos to make them as clear as possible, while also keeping them short and to the point.
Thank you so much for these. So helpful. I am doing the Data Science Specialization and feel much more confident after the extra bit of help.
Great to hear! You are very welcome, Unam. Good luck with the rest of the Specialization!
Excellent series of videos, very helpful
rajkiran boggala Thanks for your kind comment! Let me know if you have any other questions about Git or GitHub that I can answer!
Hello, and thank you in advance for your time!
So, I want to know if I understand a certain concept here: When you use Windows Note Pad to edit your markdown file, is that the same thing as going to R Studio to edit it?
Oh Kevin, thank goodness for you! You are born to teach my friend!
What a nice compliment, you made my day! :)
this was great, good balance of detail yet quick and to the point.
Thanks!
Very informative video in a very simple way. Thanks a lot.
Most welcome!
Thanks so much for posting these. Really helpful in understanding what I am doing and helping me through my courses.
+Siobhan Peterson You're very welcome :)
all these years later
this vid really helped ty
Great to hear! 🙌
Kevin, thanks a lot for the videos, they are very very well done, I am reviewing them now and doing the same steps, plus just trying stuff =)
Thank you, thank you, thank you! No has been able to explain it as simple as you.
Great to hear! :)
Thank you, thank you, thank you! Your tutorials are so clear and simple!
Thank you so much! 🙏
The videos helped quite a bit.
Thank you very much for putting them together.
Thank you! I was trying to figure what I was doing wrong pushing my file to github and this video helped me a lot!
Glad it helped!
the best video out there for this - thank you so much!!
Thanks!
thank you for this ... confirmed 7 years after and this still works
Great!
Thank you for the help, I finally got my R assignment submitted thanks to you.
Tribal-Tech Fan You're welcome! Happy to help.
You are a fantastic instructor. Thank you so much for your videos.
Thanks very much for your kind words!
Found this really helpful, thanks!
Thank you so much. Taught me everything I needed to know and was super clear!
I'm so glad!
Over an hour of banging my head on the keyboard, this 5 minute video answer the exact question I looking that I had.
rusty7834 Yes! I remember that exact feeling from when I was learning Git. That's exactly why I created these videos :)
Very helpful. Thanks, man!
You're welcome!
Thank you so much for the clear explanation video
You're very welcome!
Thank you so much for posting this! :) Very helpful!
You are very welcome, I'm glad you found it to be helpful!
can u please say me, from where this markdown live editor got excited from?? i dint get your point over there.
Thank you for these videos. They helped me to complete my assignments - they were clear and easy to follow. Very grateful.
Shelly-Ann Johnson I'm very happy to help! Thanks for your kind comments :)
Thanks you are awesome! Was able to finally commit and push with ease on an existing branch
:)
Great! :)
Very helpful videos. Just saw a bunch of them. A good place to get started for beginners like me.
Tushar Tyagi Excellent, glad they have been helpful to you! :)
I love it even more that you reply to all of our silly comments.
A lifesaver; thanks. Very clear and easy to follow.
+jwgenmed You're welcome! Glad to hear.
Best tutorial ever....! Helpful... & Thanks buddy
You're very welcome!
This was quick and easy to understand. Saved my lots of time, Thanks dude! +1
You're very welcome! Thanks for your comment!
Thanks a lot for your patience. You are a very good teacher. Thanks god I have found you, now my life will be easier! bless you
Thank you so much for your kind words! :)
My friend your tutorials are perfect you are good teacher!
Thanks!
You are awesome Excellent explanation.You made my day.Thanks a ton!
+kiran kumar You're very welcome... thank you for your kind comments!
Thank you so much for making these videos!
kitchenjhc1, you are very welcome!
you sir just saved my whole life!!!
🙌
awesome tutorial! Thanks!
You're welcome!
Thanks for the video. Very helpful
+augustin tete You're welcome!
Thanks for the video. Helped me out where google could not. Thumbs up!
Awesome! Glad I could help!
Thank you for the video. It just helped me submit the R files for the course Project.
Devanshu Gupta Awesome... congratulations!
Thank you, I learn better visually than I do with words :D
+FlyteWizard You're welcome!
Very helpful now i know what i was doing and how i will do it.
Great job!!
Thank you Kevin, it helped me a lot!
Great to hear!
Thank you so mush for these perfect tutorials of Git and Github. I had lot of difficulties in learning how to work with Git and Github, I could not find a good tutorial for that. You did really good job in teaching this topic, you made it easy to understand. I think you have been born to be a teacher. as AlyMinx said, you are a ROCK
Wow! What a kind thing to say... thank you so much! :)
Thank you so much! This is really, really helpful!!!
+Judith Deurvorst You're very, very welcome! I'm glad to help!
You Sir, ROCK! Wow these videos have helped A LOT for me. I've never even heard of GitHub until recently and felt very overwhelmed with the interface. This video helped clear up so many things up for me. Im also very glad that you have a transcript of your tutorials in every vid. Looking forward to your future videos!!!!
Wow, thanks for your enthusiasm, I really appreciate it! Git and GitHub can definitely be overwhelming at first. I had hoped the transcripts would be useful. I actually have a new video (unrelated to Git/GitHub) coming out soon!
Thank you So Much.... Really you create a great lesson :)
Thanks! Very helpful.
+a26z1c2b3 You're welcome!
Thank you for such an informative video!
You're welcome!
Hi,
Thanks for the video. What exactly did you drag and drop to open new.md in the video? Once you type touch new.md, where is it?
Great question, Marc. When you use the "touch" command, the file appears in the directory you are currently working in (aka your "working directory"). To open the file, I just dragged it from a Windows Explorer window and dropped it into Notepad. (Alternatively, I could have used the File -> Open menus to open it.)
A god send of a tutorial, holy fuck I think these videos need to be sent out to all universities
Really great stuff.
Thanks, much appreciated!
Thank you very much bruh you helped a lot!!
Great to hear!
This is wonderful - thank you so much!!!!
+Julia Charles You're welcome!
Your videos are very helpful and you explain things very well. One question (maybe basic) - why is staging needed before committing?
Subhajit Gupta Great question! You need to stage your changes before committing because Git does not presume that you want to include all detected changes in any given commit. In other words, Git wants you to decide what to include in a given commit (which you signal by staging those changes), rather than automatically including all detected changes when you commit.
Data School Thanks!
Thank you. Its really help.
+Sourabh Shrivas You're welcome!
Very helpful. But I have a question. What do I do if I pushed several commits with a commit message that I mistakenly wrote, how do I change them so each one of them has an individual new commit message ?
I'm sorry, I'm not sure how to do that!
Awesome. I used it to push my first markdown to the Coursera Course. Awesome and simple.
+Gautam Anand Excellent, and congratulations!
Nice Videos series.... this one and and also of pandas series.... loved the way you explain things so that everything is understandable...
looking forward to your other wonderful video series.
Excellent! Glad these videos are helpful to you! My machine learning series (with scikit-learn) might be of interest to you: ruclips.net/p/PL5-da3qGB5ICeMbQuqbbCOQWcS6OYBr5A
Thanks for the great video
You're very welcome!
thank you man... you make so simple what everyone show so wierd
You're welcome!
Lifesaver x1000 🙌🏾
Thanks!
You're amazing. I've never commented on RUclips, I just created an account to say that. The Git portion of The Data Scientist's Toolbox was particularly frustrating. These videos were fantastic.
A ElRazi Thank you!! What a nice comment!
Dude you are awesome thank you
😄
Thanks for your video. I have a doubt. When you push your code to master, don’t you need to checkout the code?
Not sure I understand, sorry!
Bahut bahut dhanyawaad (very very thank you )
You're welcome!
thanks a lot. by the way what keyboard did you use here?
Do you mean what keyboard do I type with? I use the Dvorak layout.
Thank you for your videos....regarding #8, I am not able to open the readme.md in notepad because Notepad doesn't recognise .md ......any suggestions?
One way to open README.md in Notepad is to click File->Open, and then change the filter from "Text Documents" to "All Files". Another way is to open Notepad, and then drag and drop README.md into Notepad.
Thanks a lot!
Very helpful!!! Saved me so much headache
That's great to hear!
Soooo. In the read me, of a cloned source code, I could then change the name and all the attributes obviously and that would show up I'm sure after checking the status. And then I could push the changes to GitHub, now, if I'm trying to clone let's say for an example Bitcoin when I pushed my new version, that will be viewable, will that make it a fork? Or how does that work?
Maybe this will help? www.dataschool.io/simple-guide-to-forks-in-github-and-git/
Thanks! Helped me alot!
You're welcome!
omg thank you thank you for explaining it so clearly!! I cannot tell you how many resources I went through that were supposedly for github beginners, but explained things in github jargon that I don't fully understand because (duh!) I'm a beginner. Watching your videos has definitely decreased my frustration with github. Maybe I will eventually even stop hating it.
Ramsey Cardwell Awesome!! Thanks so much for your kind comments. I created this video series because when I learned Git and GitHub, I experienced the same exact frustration. Glad I could be helpful! :)
Thank you!!
Maybe a dumb question but what about pull requests? If you push, then the changes are implemented on the remote, but what if you need it to be a pull request before changes are made? Is that possible through git or how would you go about that?
This might help: www.dataschool.io/how-to-contribute-on-github/
Great, thanks a lot!!
You're very welcome!
you're awesome, thank you.
You're welcome!
Thanks Master !
+Hugo Seleiro Ha! You're welcome :)
when I give that touch command, it is showing permission denied...wt to do?!
Thanks this helped
Great to hear!
You Are Awesome!
Thank you!
This is the best git tutorial I have come across. You have cleared all the confusion I had, many thanks for that. One thing that worried me is that at the end of the video when you typed: git push origin master, you were asked to enter your passphrase for key '/c/users/kevi/.ssh/id_rsa'. I was not asked enter anything! why is that?
I really need to know why!
2-: I think you said you typed your password maybe you meant passphrase ? I am new to ssh technology and read lately that passphrases should contain between 15 and 20 characters which can make a bit awkward to type so often, is that correct. Once again many thanks to you for clearing things for me and good luck to you and your family
Thanks for your kind words! 🙏
I think the difference was due to how I had set up the authentication (SSH vs HTTPS). Hope that helps!