In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what Git commands are commonly used in java development. I hope you will gain something after reading this article. Let's discuss it together.
I. create a new code base
# create a new Git code base in the current directory
$git init
# create a new directory and initialize it as a Git code base
$git init [project-name]
# download a project and its entire code history
$git clone [url]
II. Configuration
The settings file for Git is .gitconfig, which can be in the user's home directory (global configuration) or in the project directory (project configuration).
# display the current Git configuration
$git config-list
# Editing Git configuration file
$git config-e [--global]
# set the user information when submitting the code
$git config [--global] user.name "[name]"
$git config [--global] user.email "[email address]"
III. Add / delete files
# add the specified file to the temporary storage area
$git add [file1] [file2]...
# add the specified directory to the temporary storage area, including subdirectories
$git add [dir]
# add all files in the current directory to the temporary storage area
$git add.
# Delete the workspace file and put this deletion in the scratch area
$git rm [file1] [file2]...
# stop tracking the specified file, but the file will remain in the workspace
$git rm-- cached [file]
# rename the file and put the rename in the scratch area
$git mv [file-original] [file-renamed]
IV. Code submission
# submit temporary storage area to warehouse area
$git commit-m [message]
# submit the designated files of the temporary storage area to the warehouse area
$git commit [file1] [file2]...-m [message]
# submit the changes in the workspace since the last commit, directly to the warehouse area
$git commit-a
# display all diff information when submitting
$git commit-v
# use a new commit to replace the previous submission
# if there are no new changes in the code, it will be used to rewrite the submission information of the last commit
$git commit-- amend-m [message]
# redo the last commit and include new changes to the specified file
Git commit-- amend [file1] [file2]...
V. Branch
# list all local branches
$git branch
# list all remote branches
$git branch-r
# list all local and remote branches
$git branch-a
# create a new branch but still stay in the current branch
$git branch [branch-name]
# create a new branch and switch to it
$git checkout-b [branch]
# create a new branch and point to the specified commit
$git branch [branch] [commit]
# create a new branch and establish a tracking relationship with the specified remote branch
$git branch-- track [branch] [remote-branch]
# switch to the specified branch and update the workspace
$git checkout [branch-name]
# establish a tracking relationship between the existing branch and the specified remote branch
$git branch-- set-upstream [branch] [remote-branch]
# merge the specified branch to the current branch
$git merge [branch]
# Select a commit and merge it into the current branch
$git cherry-pick [commit]
# Delete branches
$git branch- d [branch-name]
# Delete remote branch
$git push origin-- delete [branch-name]
$git branch-dr [remote/branch]
VI. Label
# list all tag
$git tag
# create a new tag in the current commit
$git tag [tag]
# create a new tag in the specified commit
$git tag [tag] [commit]
# View tag information
$git show [tag]
# submit the specified tag
$git push [remote] [tag]
# submit all tag
$git push [remote]-- tags
# create a new branch and point to a tag
$git checkout-b [branch] [tag]
7. View information
# showing files with changes
$git status
# display the version history of the current branch
$git log
# display the commit history and the files that have changed each time the commit has changed
$git log-stat
# display the version history of a file, including file renaming
$git log-- follow [file]
$git whatchanged [file]
# display each diff related to the specified file
$git log-p [file]
# shows who and when the specified file was modified
$git blame [file]
# display the difference between the staging area and the workspace
$git diff
# display the difference between the staging area and the previous commit
$git diff-- cached [file]
# display the difference between the workspace and the latest commit of the current branch
$git diff HEAD
# show the difference between two submissions
$git diff [first-branch]... [second-branch]
# display the metadata and content changes of a submission
$git show [commit]
# display a file that has been submitted for a change
$git show-- name-only [commit]
# display the contents of a file when a submission is made
$git show [commit]: [filename]
# display the most recent submissions of the current branch
$git reflog
8. Remote synchronization
# download all changes to the remote warehouse
$git fetch [remote]
# display all remote warehouses
$git remote-v
# display information about a remote warehouse
$git remote show [remote]
# add a new remote repository and name it
$git remote add [shortname] [url]
# retrieve the changes in the remote warehouse and merge with the local branch
$git pull [remote] [branch]
# upload the specified local branch to the remote warehouse
$git push [remote] [branch]
# forcibly push the current branch to the remote warehouse, even if there is a conflict
$git push [remote]-- force
# push all branches to remote warehouse
$git push [remote]-- all
IX. Revocation
# restore the specified files of the temporary storage area to the workspace
$git checkout [file]
# restore a specified file of a commit to the workspace
$git checkout [commit] [file]
# restore all files from the previous commit to the workspace
$git checkout.
# resets the specified file of the staging area, which is the same as the previous commit, but the workspace remains the same
$git reset [file]
# reset the staging area and workspace to be consistent with the previous commit
$git reset-hard
# reset the pointer of the current branch to the specified commit, and reset the temporary storage area, but the workspace remains unchanged
$git reset [commit]
# reset the HEAD of the current branch to the specified commit, and reset both the staging area and the workspace, consistent with the specified commit
$git reset-- hard [commit]
# reset the current HEAD to the specified commit, but leave the staging area and workspace unchanged
$git reset-- keep [commit]
# create a new commit to undo the specified commit
# all changes to the latter will be offset by the former and applied to the current branch
$git revert [commit]
X. other
# generate a package that can be released
$git archive
After reading this article, I believe you have a certain understanding of "what are the common Git commands in java development". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
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: 301
*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.