In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you how to install and use Git and GitHub on Ubuntu Linux, the content is easy to understand, I hope you can learn, after learning, there will be gains, the following let Xiaobian take you to have a look.
A brief introduction to Git
Git is an open source version control software developed by Linus Torvalds in 2005 to help manage Linux (R) kernel development, as stated in the documentation provided:
Git is a fast, scalable, distributed version control system with a rich command set that provides advanced operations and full access to internal systems.
Github is a treasure trove of some of the world's best software projects contributed selflessly by developers around the world. This seemingly simple but powerful platform has been praised by the open source community because it has greatly helped developers who are interested in developing large-scale software.
This wizard is a quick guide to installing and using GitHub. This article will also cover topics such as creating a local repository, how to link this local repository to a remote repository that contains your project (so that everyone can see your project), and how to submit changes and eventually push all local content to Github.
Please note that this wizard assumes that you have a basic understanding of Git terminology, such as push, pull request (PR), submission, warehouse, and so on. And I hope you have successfully registered on GitHub and written down your GitHub user name, so let's get down to business:
1. Install Git on Linux
Download and install Git:
Sudo apt-get install git
The above commands apply to Ubuntu and should work on all the latest versions of Ubuntu. They have been tested on Ubuntu 16.04 and Ubuntu 18.04 LTS (Bionic Beaver), and should also work in future versions.
2. Configure GitHub
Once the installation is complete, the next step is to configure the GitHub user's configuration details.
Git has a tool called git config, which allows you to get and set configuration variables that control all aspects of the appearance and operation of Git. These variables can be stored in three different locations:
1./etc/gitconfig file: contains values that apply to all users and all libraries of the system. If you pass the parameter option'--system' to git config, it will explicitly read and write the file.
2.~/.gitconfig file: specific to your users. You can make Git read or write to this particular file by passing the-- global option.
3. The config file located in the git directory (i.e. .git / config): no matter what library you are currently using, specifically point to that single library. Each level overrides the value of the previous level. Therefore, the value in .git / config overrides the same value in / etc/gitconfig.
On Windows systems, Git looks for the .gitconfig file in the $HOME directory (for most people, under C:\ Documents and Settings\ $USER). It also looks for / etc/gitconfig, although it is relative to the Msys root directory. This could be anywhere you decide to install Git when you run the installer in Windows.
Please use the following two commands and be sure to replace user_name with your own GitHub user name and email_id with the email you created your GitHub account.
Git config-global user.name "user_name" git config-global user.email "email_id"
The following picture shows an example of how to configure the above command with my GitHub user name: "akshaypai" and my email address "abc123@gmail.com".
3. Create a local warehouse
Create a directory on your system. It will be used as a local repository, and later it will be pushed to the remote warehouse of GitHub. Use the following command:
Git init Mytest
If the directory is created successfully, you will see the following message:
Initialized empty Git repository in / home/akshay/Mytest/.git/
This line of information may vary depending on your system.
Here, Mytest is the directory created, and init converts it into a GitHub repository. Change the current directory to the newly created directory.
Cd Mytest
4. Create a new README file to describe the warehouse
Now create a README file and enter some text, such as "this is git setup on linux". README files are generally used to describe what the repository is used to place or what the project is about. For example:
Gedit README
You can use any text editor. I like to use gedit. The contents of the README file can be:
This is a git repo
5. Add the files in the warehouse to an index
This is a very important step. Here we will add an index to all the content that needs to be pushed to GitHub. These may include text files or applications that you joined the repository for the first time, or edits to existing files (an updated version of the file).
Now that we have the README file, let's create another file, such as a simple C program, which we call sample.c. The contents of the document are:
# includeint main () {printf ("hello world"); return 0;}
Now we have two files. README and sample.c.
Add them to the index with the following command:
Git add READMEgit add smaple.c
Note that the git add command can add any number of files and directories to the index. Here, when I say "index," I mean a buffer with a certain amount of space that stores all files or directories that have been added to the Git repository.
6. Add the changes to the index
After all the documents have been added, you can submit them. This means that you have identified the final file changes (or additions), and now they are ready to be uploaded to our own warehouse. Use the command:
Git commit-m "some_message"
"some_message" in the above command can be some simple information such as "my first submission" or "edited readme file", and so on.
7. Create a warehouse on GitHub
Create a warehouse on GitHub. Please note that the name of the warehouse must be exactly the same as the name of the warehouse you created locally. In this case, it's "Mytest". Please log in to your GitHub account first. Click the "+" symbol in the upper right corner of the page and select "create nw repository". Fill in the details as shown in the figure below and click "create repository".
Once created, we can push the local warehouse to the warehouse under your name in GitHub and connect to the warehouse on GitHub with the following command:
Please note: be sure to replace "user_name" and "Mytest" in the path with your GitHub username and directory name before running the following command!
Git remote add origin https://github.com/user_name/Mytest.git>
8. Push the files from the local warehouse to the GitHub warehouse
The final step is to push the contents of the local warehouse to the remote warehouse (GitHub) with the following command:
Git push origin master
Type the login name and password when prompted
The following picture shows the process from step 5 to step 8
The above pushes all the contents (files) in the Mytest directory to GitHub. For future projects or creating new warehouses, you can start directly from step 3. Finally, if you log in to your GitHub account and click on your Mytest repository, you will see these two files: README and sample.c have been uploaded and shown in the following image:
The above is about how to install and use Git and GitHub on Ubuntu Linux. If you have learned knowledge or skills, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.