Git commands list


SUBMITTED BY: Guest

DATE: Jan. 24, 2019, 1:42 a.m.

FORMAT: Text only

SIZE: 20.5 kB

HITS: 231

  1. Git commands list
  2. => http://dorrimidde.nnmcloud.ru/d?s=YToyOntzOjc6InJlZmVyZXIiO3M6MjE6Imh0dHA6Ly9iaXRiaW4uaXQyX2RsLyI7czozOiJrZXkiO3M6MTc6IkdpdCBjb21tYW5kcyBsaXN0Ijt9
  3. Git is distributed version control system. I will be fixing later today. Since you'll see the output from many Git commands in the terminal, it's best to have some pretty colors for the output.
  4. Git only knows what to commit when it's tracking files. Add the specified remote repo to your git config file. How can you know which exact app version is the one you need?
  5. The directory will be created automatically and will have the same project name as the remote repository. Install Git There are a few different ways to install git from source or for Linux but the purpose of this page is to focus on git commands, so I am going to assume you are installing git on a Mac. Running the command with force deletes the file. Hopefully you've registered your real name and email. You can create an account on GitHub and for your project. The terminal is a basic tool that all developers should understand. Probably, in creating this post, I will not need to look at this again, as the sheer fact of composing this list and explaining it all will burn these into my brain forever. Imagine that you explore a new territory and you mark the main path to water with poles each 10 to 15 meters.
  6. Learn Git Command with Practical Examples on Linux - In all its complexity, Git works quite simply: you first need to create a local repository in your project's root directory folder.
  7. Having a Git cheat sheet taped to our table doesn't help. Git is very complicated, as you can't learn all its concepts by just using it. Sadly, your life as a web developer will also be complicated without Git, and here's why. The 1 problem of life without Git is that you can't adequately manage project versions. When you start a new project, you create several basic files. These basic files constitute the first version of your application. But the next day you develop the first feature, and thus you create a second version of the app. Still later, you decide to rework the first feature. Therefore, you create a third version of your app. When you remove or rework code, you can't restore its previous state read: version. Without Git, you'd have to save each version of the project to a different place. Restoring a project from several places, however, isn't a viable option. How can you know which exact app version is the one you need. Git, on the other hand, can tell you what project version you're restoring. Here's another problem of development without Git: several developers git commands list work on the same project, and they'll also need access to previous app versions. How can you share your code with the entire development team. I git commands list use Dropbox, Google Drive, OneDrive, a flash drive… any other drive to store my code and share it with everyone. But again, how can you know for sure which version of code is the latest. And if your friend wants to merge your code with his version in the same file, would you like to go line by line to see whose code will be merged into which part of a file. Git easily solves both problems we've described: managing project versions and sharing code among developers. But to make Git our best friend, we should understand how Git works. To do so, we should also start using basic Git commands. A version control system is simply software that lets you effectively manage application versions. These capabilities listed above don't tell how Git actually works, however. In all its complexity, Git works quite simply: you first need to create a local repository in your project's root directory folder. Afterwards, Git can track project files and directories and add them to the repository. We're talking about a repository now. Git A repository is just a directory a folder in your project's root directory. Throughout the entire article we'll use the git commands list directory, not folder. You can't see repositories in your filesystem as they're hidden. Let's use our imagination to understand repositories. If you store your stuff code at home on a computer with a Git directoryyou store your stuff locally. So a repository on your own computer will be called local. A git commands list repository is like a public storehouse located in a different building. You may have heard about remote repositories such as GitHub, BitBucket, and GitLab. They're like storehouses for code. Thanks to Git, you can copy your entire project to a remote repository while keeping it in a local repository as well. Why do we use local and remote repositories. Let's explain a little bit. In the real world, you git commands list have exactly the same stuff at home and in a storehouse. If your things disappear from home God forbid. And you'll still lose some valuables the original things. With GitHub or BitBucket, however, it's a different story. Remote storehouses repositories like GitHub or BitBucket store exactly the same code that you have in your local repository on your home computer. If your code disappears from your local repository, you can restore absolutely the same code from a remote repository. A remote repository also serves as a central hub to which members of a web development team can connect to access project code. By now it should be clear what Git is and what repositories are. But we also need to mention two methods to run Git commands. But you can also run terminal commands for Git. The terminal will be your paper on which you'll write Git commands. For the purpose of this article, we'll use the terminal also called the command line to run Git commands. The terminal is a basic tool that all developers should understand. Lastly, you need to install Git on your git commands list. Once you have Git installed, you can move on to basic Git commands with examples to make friends with Git. You can consider the following sections a Git tutorial. Configuring Git When you come to a bank for the first time and ask to store your money there, they give you a bunch of paperwork to fill out. Before you can use banking services, you have to register with the bank. Git wants you to do the same register with Git before you start using a repository. To tell Git who you are, run the following two commands: You've completed the first configurations. Hopefully you've registered your real name and email. If not, you can git commands list change them by running the same commands once more, but using your real name and email this time. Let's quickly review the syntax of Git commands. No matter how many projects with separate local repositories you create, Git will use the same username and email to mark your commits. There's one thing to configure before you start using Git. Since you'll see the output from many Git commands in the terminal, it's best to have some pretty colors for the output. To turn on code highlighting, just run the following command: That's enough for a start. You've got the feeling of Git by running several simple configuration commands. But you haven't actually used Git yet. Let's try some real Git, so to speak. We'll finish each section with a Git commands list. Here are the basic Git commands you've learned so far: Starting a New Local Repository with Git To continue with our bank metaphor, we need to explicitly ask the bank to open a new safe deposit box to store our effects read: code. And you'll get a confirmation that your deposit box is ready. You might want to know the status of your box: does it store anything yet. To know the Git status, you'll need to run: The message above presents a few new terms, so let's clarify what they mean. Git Branches You can consider branches in Git as paths. Imagine that you explore a new territory and you mark the main path to water with poles each 10 to 15 meters. This main path is like the master branch, and the poles are like commits. We'll talk more about branches in the last section of the article. For now, it's sufficient to know that Git has a base branch called the master branch. Git Commits A commit to a repository is a snapshot of the current state of the project's root directory. Since this explanation doesn't really tell anything, we need to delineate the underlying concept. Let's say you're working with a bunch of papers. You've written ten texts about animals on separate sheets of paper and you want to note what texts they are and when you wrote them. The last thing you do is you gather those ten copies, pin the commit paper on top of them, and lay them in a drawer. The next day you rewrite the original texts, then get the copies from your drawer and compare the texts. This is basically what Git does. You create files and write code in them. When you're ready, you commit your files to a repository: you create copies of files and lay them in a drawer a repository. Our inner nerd wants to specify that Git doesn't actually push copies of files to the repository; Git creates a light representation of the project files for performance benefits. Each day you write that commit message and add new texts. Git creates a history of your commits, so you can trace back to the very beginning of the project development to see what files have been changed or added, who added or changed them, and when. Git only knows what to commit when it's tracking files. We've explained three basic Git concepts you need to know, but we've also moved far away from explaining Git commands. Nevertheless, it's crucial to grasp Git's basic concepts to understand how Git commands work. Now that we've explained the meaning of Git concepts, we can get back to the commands. Our safe deposit box repository is empty. To do anything further, we need to populate the root folder with at least one file. Now we can move on to the next step. Git commands list conveniently informs us that we've added a new file to the project. But that isn't enough for Git. The following section will uncover the basic Git commands for working with the staging area. Here are the basic Git commands you've learned so far: Staging Files with Git Before we cover simple Git commands used for staging files, we need to explain what the staging area is. Let's say you want to move some of your valuable effects to a lock box, but you don't know yet what things you'll put there. For now, you just gather things into a basket. You can take things out of the basket if you decide that they aren't valuable enough to store in a lock box, and you can add things to the basket as you wish. With Git, this basket is the staging area. When you move files to the staging area in Git, you actually gather and prepare files for Git before committing them to the local repository. To let Git track files for a commit, we need to run the following in the terminal: The status has changed. Git knows that there's a newly created file in your basket the staging areaand is ready to commit the file. We'll get to committing files in the next section. What if you create or change several files. With a basket as your staging area, you have to put things into the basket one by one. Committing files to the repository individually isn't convenient. Let's assume you've added another three files to the root directory: my-file. Now you want to add all of them to the staging area. Instead of adding these files separately, we can add them all together: Instead git commands list listing file names one by one, you can use a period — yes, a simple dot — to select all files under the current directory. Git will git commands list all new or changed files and shove them into the basket the staging area all at once. That's even more convenient, isn't it. But Git can do even better. But the root directory may contain many other directories with files. How can we add files from those other directories plus the files in the root directory to the staging area. Remember when we told you that you can take things out of your imaginary basket. Git can also take things out of its basket by removing files from the staging area. We've provided enough Git commands to add and remove files to and from the staging area. Now it's time to get familiar with committing files to the local repository. Here are the most common Git commands you've learned so far: Committing Changes to Git Let's start with a quick overview of committing to the Git repository. By now, you should have at least one file tracked by Git we have three. As we mentioned, tracked files aren't located in the repository yet. We have to commit them: we need to carry our basket with stuff to the lock box. There git commands list several useful Git commands to do almost the same: move commit files from the staging area an imaginary basket to the repository a lock box. There's nothing difficult about committing to a repository. Lastly, type in your commit message. Note that we didn't use the past tense. A commit message must tell what your commit does — adds or removes files, updates app features, and so on. We actually don't need this information; it only confirms that the commit was successful. So, what have we done so far. We added files to a project directory in the first section. Then we added files to the staging area, and now we've committed them. That's enough to get the idea of Git's flow. But let's get back to committing files. When working on a project, chances are you'll modify some files and commit them many times. Git's flow doesn't really change for adding modified files to a new commit. In other words, every time you make changes you'll need to add a modified file to the staging area and then commit. But this standard flow is tedious. And why should you have to ask Git to track a file that was tracked before. The question is how can we add modified files to the staging area and commit them at the same time. Don't forget to write a commit message, though. There will be times when you'll regret committing to a repository. Let's say you've modified ten files, but committed only nine. How can you add that remaining file to the last commit. And how can you modify a git commands list if you've already committed it. There are two ways out. You can now add another file to the staging area and commit, or you can amend files and commit them. By this time, you've done some work with Git on your computer. You've created files, added them to the staging area, and committed them. But these actions only concern your local repository. When working in a team, you'll also use a remote repository. What are the basic Git commands to work with remote repositories. The answer is in the following section. You'll use several important Git commands to move push your code from a local repository to a remote repository and to grab pull your team's collective code from a remote repository. First things first, you need to create a remote repository. We'll use GitHub for this section. You can create an account on GitHub and for your project. Just start a project and give it a name. Lastly, there's a link to your project on GitHub. Once you run the command above, Git will connect your local and remote repositories. But what does this liaison actually mean. Can you already access your code online. All you did for now is signed papers so that the remote lock box GitHub can accept various items your code from your home drawer local repository. To actually copy your things to a remote lock box, you need to personally carry them to it. What we also specified is the server our local repo is connected to origin and the branch we're pushing, which is master. As we can see, Git tries to simplify things as much as possible. Is this the happy ending. Once you push code to a remote repository, you have to enter your username and password registered with that remote repository. Git offers a way out of this inconvenience, however. Let's say your drawer with all your valuables has disappeared from your home. Now you want to get your git commands list back from the lock box, kind of like cloning them. Git can clone an entire project from a remote repository. We only need to pass it a link to the GitHub project. The directory will be created automatically and will have the same project name as the remote repository. If you don't like the name of the repository you're cloning, git commands list pass your preferred name to the command: So far, you've pushed git commands list changes from a local repository to a remote repository and cloned a remote repository. Pushing changes to GitHub or BitBucket is great. But when other developers push their changes to a remote repository, git commands list want to see their changes on your computer. That is, you'll want to pull their code to your local repository. Wait, but you said I could clone a repository. Why do I have to pull something. Anonymous Developer That's a valid question, so let's clarify. Cloning a repository is very different from pulling from a repository. Git will only pull updates to make sure that your the local repository is up to date. Basically, that's all you need to know about pushing, pulling, and cloning with Git. One set of basic Git commands is left, though. Remember how we mentioned branches in the beginning of the article. Why do we ever need branches. And what are the basic Git commands to view, add, and delete branches. The Git cheat sheet continues to grow: List of Git Commands for Working with Branches You'll use multiple branches for your projects. Branches are, arguably, the greatest feature of Git, and they're very helpful. Thanks to branches, you can actively work on different versions of you projects simultaneously. The reason why we use branches lies on the surface. If you have a stable, working application, you don't want to break it when developing a new feature. Therefore, it's best to have two branches: one branch with a stable app and another one for developing features. Then again, when you complete a feature and it seems to be working, some bug may still be there. And bugs must not appear in a production-ready version. Thus, you'll want to have another branch for testing. In the simplest terms, you'll use branches to store various versions of your project: a stable app, an app for testing, an app for feature development, and so on. Actually, what we've described is just one possible way but certainly not the only way to organize branches. How many branches you use and when you should create branches is subject to discussions within a web development team. Before starting a project, developers should decide how and when to create branches and then follow established rules until the project is complete. Managing branches in Git is simple. In our app, we have only one branch — master. But an application under development is far from being complete, and we need git commands list develop new features. Let's say we want to add a user profile feature. In other words, if you create a branch and start changing code right git commands list, you'll still be editing the previous branch, not the new one. After you've created a new branch to develop git commands list feature, you need to switch to the new branch before you get to work on a feature. You can now freely change any file, create and delete files, add files to the staging area, commit files, or even push files to a remote repository. Whatever you do under the user-profile branch won't affect the master branch. You're saying that I can do whatever I need in a new branch and it won't change the master branch at all. But once I finish developing a feature, how can I move it from that development branch to the master. Do I need to copy-paste. You're stuck on the third step. What should you do next. To merge a secondary branch into the main branch which can be a master, development, or feature branchfirst switch back to the main branch. Git earns another point for improving the workflow. Here's an extensive list of the most used Git commands with examples: A Quick Recap Git is a great tool to aid your development process. From the point of view of web developers, Git is a huge heap of commands. There are dozens of Git commands you should know. Solid knowledge of the basic commands for the features listed above is enough for beginners. Try these basic Git commands for yourself and you'll see that the devil isn't as black as he's painted.

comments powered by Disqus