In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "Git simple and practical operation steps and commands". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Git simple and practical operating procedures and commands" bar!
# preparation in advance:
1 ️installation: install Git for Windows/Mac
After the installation of Git under Windows is complete, open the terminal or right mouse button to open the Git Bash terminal window directly from the start menu-> Git-- > Git Bash.
2 ️account: configure the user name and mailbox of Git
Git config-- global user.name 'test'
Git config-- global user.email 'test@123.com'
Test whether it can be pushed to a remote warehouse
1.git Clone the latest version of the remote repository to local
Git clone http://10.20.30.4:8080/test/test.git
two。 Enter the local warehouse directory (workspace)
Cd test
3. Create a new file README.md test
Touch README.md
4. Add the specified file README.md to the staging area
Git add README.md
5. Pull the latest code from the remote repository (default origin) before submission
Git pull origin master
6. View status before submission
Git status
7. Submit it to the local warehouse.-m is followed by the version note information of this submission, that is, a new README file is added.
Git commit-m "add README"
8. View status after submission
Git status
9. Push to the remote repository (not needed after the first use of-u), that is, push the current master branch to the corresponding remote branch origin
Git push-u origin master (first push)
Git push origin master (simplified command)
Note because the remote library is empty, when we push the master branch for the first time, with the-u parameter added, Git will not only push the local master branch content to the remote new master branch, but also associate the local master branch with the remote master branch, which can simplify the command when pushing or pulling later.
Extension command description:
Operation instructions for 1.git add related commands
# add all files in the current directory to the temporary storage area
Git add.
# add the specified file to the temporary storage area
Git add [file]
# for example, add test.txt files to the temporary storage area
Git add test.txt
# add the specified directory to the temporary storage area, including subdirectories
Git add [dir]
# for example, add a test/ directory to a temporary storage area
Git add test/
Operation instructions for 2.git commit related commands
# submit the temporary storage area to the local warehouse, and message represents the submitted version description information
Git commit-m [message]
# submit the specified files of the temporary storage area to the local warehouse
Git commit [file]-m [message]
# for example, submit the test.txt of the temporary storage area to the local warehouse
Git commit test.txt-m 'add test.txt'
# replace the previous submission operation with a new commit
Git commit-amend-m [message]
3.git delete file and undo modify command
# git deletes the specified file
Git rm test.txt
# after submission, the file is really deleted in the warehouse
Git commit-m 'delete test.txt'
# undo the modification
Git checkout-test.txt
Operation instructions for 4.git branch related commands
# list all local branches
Git branch
# list all remote branches
Git branch-r
# list all local and remote branches
Git branch-a
# create a branch but remain at the current branch
Git branch [branch-name]
# create a branch and switch to it
Git checkout-b [branch-name]
# switch to the specified branch and update the workspace
Git checkout [branch-name]
# Delete branches
Git branch- d [branch-name]
# Delete remote branch
Git push origin-- delete [branch-name]
Operation instructions for 5.git branch merge command
# pull the latest code of remote warehouse before merge
Git fetch [remote]
# merge branch branch to the current branch, and conflict resolution occurs
Git merge [branch]
6. Version fallback
# View the history of version
Git log
# fallback to the previous version
Git reset-- hard head ^
# fallback to the previous version
Git reset-- hard head ^ ^
# git reset-- hard [version number]. The command to obtain the version number is as follows
Git reflog
Other commands:
# display the current change file
Git status
# display the current version history
Git log
# display the difference between the staging area and the workspace
Git diff
# display the difference between the workspace and the latest commit of the current branch
Git diff HEAD
# View remote warehouse information
Git remote
# View the details of the remote library
Git remote-v
At this point, I believe that everyone on the "Git simple and practical operating procedures and commands" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.