That command pulled in a complete copy of the repository right to your system where you can work on it, make changes, stage the changes, commit the changes, and then push the changes back to GitHub.
You don’t need to put the repository on your desktop if you don’t want to.
You can clone it anywhere.
You can even run the git clone command as soon as you open up your terminal.
I will say, though, that if you aren’t really comfortable navigating around your computer, it’s not a bad idea to have your project sitting right on your desktop where you can see it…If you ever want to just play with a project on your own, you can fork it on the GitHub website instead of cloning it.
Look up near the top right corner of the screen for the “fork” button and click it.
This will make a copy of the repository in your repositories for you to play with on your own without doing anything to the original.
Now it’s time to add some files to your project!Photo by Nadim Merrikh on UnsplashThis is all we’re about to do:git statusgit addgit commit -m " "git pushNothing to worry about!I’m thinking you probably have some files that you want to put in your new repository.
Go ahead and find your files and drag and drop them into the new folder for the repository that you created on your desktop, just like you normally would with any set of files you might want to move into a folder.
Now, check out the status of your project!Go to your terminal and get yourself into the folder for your repository.
Then rungit statusto see if everything is up to date.
(If you just dragged some files into your project folder, it definitely isn’t!) To add one of your files to the repository, you would rungit add <fileneame>Otherwise, you can add everything withgit add –allor evengit add .
These are your proposed changes.
You can do this exact same thing with brand new files and with files that are already in there but have some changes.
You aren’t actually adding anything just yet.
You’re bringing new files and changes to Git’s attention.
To commit the changes, you will start the process by runninggit commit -m “<commit message>”You’re committing the changes to the HEAD, but not to the remote repository.
(Make sure you replace that message in quotes with your own.
) After you make a change, you take a “snapshot” of the repository with the “commit” command.
You‘ll include a message on that “snapshot” with -m.
When you save a change, that’s called a commit.
When you make a commit, you’ll include a message about what you changed and/or why you changed it.
This is a great way to let others know what you’ve changed and why.
Now your changes are in the head of your local working copy.
To send the changes to your remote repository, rungit pushto push your changes right into your repository.
If you’re working on your local computer and you want your commits to be visible online too, you would push the changes up to git hub with the git push command.
You can see if everything is up to date any time by running the git status command!So now you have a GitHub repository and you know how to add files and changes to it!Congratulations!!!Learning to work with othersCollaboration is the name of the game on GitHub!Photo by Quinten de Graaf on UnsplashGitHub flowLet’s say you have a project going and you maybe have a lot of different ideas and features in mind at any given time.
Some features might be ready to go, but some might not.
Maybe you’re working with other people who are all kind of doing their own thing.
This is where branching comes in!A branch is a separate space where you can try out new ideas.
If you change something on a branch, it doesn’t affect the master branch until you want it to.
This means that you can do whatever you want to do on that branch until you decide it’s time to merge it.
The only branch that’s going to permanently change things is the master branch.
If you don’t want your changes to deploy immediately, then make your changes on a separate branch and merge them into the master branch when you’re ready.
If you’re working with others and want to make changes on your own, or if you’re working on your own and want to make changes without affecting the master branch, you want a separate branch.
You can create a new branch at any time.
It’s also pretty simple to create a branch named “new_feature” in your terminal and switch to it withgit checkout -b new_featureOnce you create a branch, you can make changes on that branch.
This makes it easy to see what you’ve changed and why you’ve changed it.
Every time you commit your changes, you’ll add a message that you can use to describe what you’ve done.
Let’s talk about checkout!git checkoutlets you check out a repository that you’re not currently inside of.
You can check out the master branch withgit checkout masteror look at the “new_feature” branch withgit checkout new_featureWhen you’re done with a branch, you can merge all of your changes back so that they’re visible to everyone.
git merge new_featurewill take all of the changes you made to the “new_feature” branch and add them to the master.
In order to create an upstream branch so that you can push your changes and set the remote branch as upstream, you will push your feature by runninggit push –set-upstream origin new_featureAfter you make some changes and decide you like them, you open a pull request.
If you’re on a team, this is when other people on your team can start checking out your changes and discussing them.
You can open a pull request at any point, whether it’s to have people look over your final changes or ask for help because you’re stuck on something.
Ummmmm…what?.Can I do that on the website?You can!Photo by rawpixel on UnsplashOne way to do this is simply by checking that button that we mentioned earlier when we were editing the README file.
Super easy!You can also create a new branch any time right on the website by going to your repository, clicking the drop-down menu near the left-middle side of your screen that says “Branch: master,” typing a branch name, and selecting the “Create branch” link (or hitting enter on your keyboard).
Now you have two branches that look the same!.This is a great place to make changes and test them out before you want to make them affect the master branch.
Creating a branchIf you’re working on a separate branch, your changes only affect that branch.
If you’re happy with your changes and you want to merge your changes to the master branch, you can open a pull request.
This is how, if you were on a team, you would propose your changes and ask someone to review them or pull in your contribution and merge them into their branch.
You can open a pull request as soon as you make a commit, even if you haven’t finished your code.
You can do this right on the website if you’re more comfortable with that.
If you’ve made some changes on your branch and you want to merge them, you canClick the pull request tab near the top center of the screenClick the green “New pull request” buttonGo to the “Example Comparisons” box and select the branch you made to compare with the original branch.
Look over your changes to make sure they’re really what you want to commit.
Then click the big green “Create pull request” button.
Give it a title and write a brief description of your changes.
Then click “Create Pull Request!”New pull requestCreate pull requestNow if this is your repository, you can merge your pull request by clicking the green “Merge pull request” button to merge the changes into master.
Click “Confirm merge,” then delete the branch after your branch has been incorporated with the “Delete branch” button in the purple box.
If you’re contributing to a project, people on the team (or the reviewer) might have questions or comments.
If you need to change something, this is the time!.If everything is good to go, they can deploy the changes right from the branch for final testing before you merge it.
And you can deploy your changes to verify them in production.
If your changes have been verified, you can go ahead and merge your code into the master branch.
The pull requests will preserve a record of your changes, which means that you can go through them any time to understand the changes and decisions that have been made.
Update and mergeIf you’re working on your computer and want the most up-to-date version of a repository, you’d pull the changes down from GitHub with the git pull command.
To update your local repository to the newest commit, rungit pull in your working directory.
To merge another branch into your active branch, usegit merge <branch_name>Git will try to auto-merge changes, but this isn’t always possible.
Conflicts might arise.
If they do, you’ll need to merge the conflicts manually.
After changing them, you can mark them as merged with git add <filename>.
You can preview your changes before you merge them withgit diff <source_branch> <target_branch>You can switch back to to the master branch withgit checkout masterYou’ll make your changes and then delete the branch when you’re done withgit branch -d new_featureThis branch isn’t available to anyone else unless you push the branch to your remote repository withgit push origin <branch>Other helpful commandsFirst of all, this is my favorite GitHub cheatsheet.
Check it out for all of the most useful Git commands!You can see the commit history of the repository if you rungit log You can see one person’s commits withgit log –author=<name> You can see what has been changed but not staged yet withgit diffNeed help remembering what command you’re supposed to run?.Trygit helpto see the 21 most common commands.
You can also type something likegit help clone to figure out how to use a specific command like “clone.
”Let’s do this!Photo by Mervyn Chan on UnsplashWhy not leave your mark and welcome everyone who’s here to learn about Git and GitHub?.We’re going to create a simple welcome wall with notes from everyone who wants to try out Git and GitHub and contribute to their first open-source project.
You can add whatever you want to the welcome wall, as long as you keep it warm and encouraging.
Add a note, add an image, whatever.
Make our little world better in whatever way makes you happy.
(If you’re an overthinker (I see you ❤️), I have a pre-written message in the README file that you can just copy and paste.
)Clone the repository, either on the GitHub website or by runninggit clone https://github.
gitCreate a new branch and add a welcoming and encouraging thought to the “welcome_wall.
You can do this on the website, but I really encourage you to try cloning the repository to your computer, opening the file with your favorite text editor, and adding your message there.
It’s just good learning!Create a pull request.
Write a quick note describing your change and click the green button to create your pull request.
That’s it!.If it’s a decent message, thought, image, or idea, I’ll merge your request and you will have successfully contributed to an open-source project.
Congratulations!!!.You did it!Photo by Pablo Heimplatz on UnsplashAs always, if you do anything awesome with this information, I’d love to hear about it!.Leave a message in the responses section or reach out any time on Twitter @annebonnerdata.
If you liked this article, you might want to check out:Getting Started with Google Colab: a simple tutorial for the frustrated and confusedThe complete beginner’s guide to data cleaning and preprocessingThe Intro to Deep Learning seriesThanks for reading!.. More details