In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "what is the centralized operation command of Git in Linux". In the daily operation, I believe that many people have doubts about what the centralized operation command of Git in Linux is. The editor consulted all kinds of materials and sorted out a simple and easy-to-use operation method. I hope it will be helpful to answer the doubt of "what is the centralized operation command of Git in Linux?" Next, please follow the editor to study!
SyntaxHighlighter
Git version # View version git config-l # View current configuration git config-- global user.name "Dean" # set user name, mailbox git config-- global user.email g.xiangyu1990@gmail.com # set user name Mailbox git config-- global alias.ci commit # set alias git config for git command-- global alias.co checkout # set alias for git command
Git warehouse (repository):
# create a local git repository and name it: git init demo# Clone a remote git repository to the specified path: git clone https://github.com/a396901990/android.git / path/workpsace
Git Branch (branch):
Git branch # View Branch git remote show origin # View all branches git branch # create New Branch git checkout # switch to Branch git checkout-b # create and switch to New Branch git branch-d # Delete Branch (- D forcibly delete) git branch-m # Local Branch rename
Git add (add):
Git add # adds files with locally specified file names or directories (new and modified, not deleted) to the staging area git add. # add all local (new and modified, not deleted) files to the staging area git add-u # add the local (modified and deleted, not added) files to the staging area git add-A # add all local changes to the staging area (git add-A = git add. + git add-u) git add-I # opens an interactive interface to add files as needed
Git delete / rename (rm/mv):
Git rm # Delete files git rm-r # Delete folder git rm-- cached # removes files from the version library, but does not delete files git mv # file rename
Git submission (commit):
Git commit-m "comment" # submit the contents of the staging area (already add) and add the comment git commit-a # add the modified files to the staging area (excluding the newly created (untracked) files), and then submit. Git commit-amend # modify submitted commit (without push) git commit-amend-m "comment" # modify commit note
Git difference (diff):
Git diff # View the difference between the working directory (working tree) temporary storage area (index) git diff-- cached # view the difference between the temporary file (stage) and the unsubmitted file (commit) git diff-- staged # as above git diff HEAD # View the difference after the last submission (HEAD represents the last commit information) git diff-stat # check See the brief results (list of files) git diff commit1 commit2 # compare the content of two submissions (it can also be branch Hash value)
Git View History (log):
Git loggit log-3 # View the previous three modifications git log-- oneline # one line displays a loggit log-p # View detailed changes git log-- stat # View submission Statistics git log-- graph # shows when information such as branching and merging occurred
Git View status (status):
Git status # check the status of your code in caching with the current working directory git status-s # output the result in short form git status-- ignored # shows ignored files
Git Storage (stash):
Git stash # Save current work progress git stash save "message" # Save progress plus description git stash list # display progress list git stash pop # restore the latest saved work progress and delete the restored work progress from the stored list git stash apply # restore the latest save work progress, but do not delete git stash drop # delete a progress Delete the latest git stash clear # by default and delete all
Git reset (reset):
Git reset-- mixed # resets the staging area like git reset without any parameters, but does not change the workspace git reset-- soft # rollback to a version without changing the staging area and workspace (direct commit if you want to submit) git reset-- hard # completely rolls back to a version to replace the staging area and workspace The local source code will also become the content of the previous version git reset # withdraw the content that was previously added to the staging area with the git add command (equivalent to the reverse operation of git add-A) git reset HEAD # HEAD effect is the same as above Because the reference reset to HEAD is equivalent to not resetting git reset filename # withdraw the file from the staging area (equivalent to the reverse operation of git add filename) git reset head ^ # reference rollback once (workspace unchanged, staging area fallback) git reset-- soft HEAD~3 # reference rollback three times (workspace unchanged, staging area unchanged)
Git revocation (revert):
Git revert commit # undo the specified commitgit revert HEAD # undo the last commitgit revert-no-edit HEAD # undo the last one and directly use the default comment git revert-n HEAD # to undo the last but not commit
Git selection (cherry-pick):
Git cherry-pick # is used to apply commit modifications from another local branch to the current branch
Git merge (merge):
Git merge # merge git merge-- no-ff # uses the no fast forward merge method, which generates a new commitgit merge while merging-- abort # tries to fall back to the pre-merge state (which may fail) git merge-- squash # merges the target branch without commit information, and finally needs to submit a commit (benefits, clean code)
Git re-base transformer (rebase):
Git rebase # git rebase-- after conflict resolution occurs when continue # executes rebase, executing this command will continue to apply (apply) the remaining patches git rebase-- skip # skip the current submission git rebase-- abort # terminate rebase, and the branch will return to the state it was before the start of rebase
Git get / pull (fetch/pull):
Git fetch # does not automatically mergegit pull # get the latest version remotely and merge it to the local git pull-- rebase # temporarily stores local changes, merges remote latest changes, merges local changes that have just been temporarily saved (does not produce synchronization of useless merge)
Git push (push):
Git push origin master # push the local branch to the master branch of the origin host git push-u origin master #-u specifies origin as the default host, and then you can use git push without any parameters. Git push-f origin #-f strong push produces a "non-direct" non-fast-forward merge git push on the remote host-- all origin # pushes all local branches to the origin master
Commands for centralized operation in Git:
1) remote warehouse related commands
Check out warehouse: $git clone git://github.com/jquery/jquery.git
View the remote warehouse: $git remote-v
Add remote warehouse: $git remote add [name] [url]
Delete remote warehouse: $git remote rm [name]
Modify the remote warehouse: $git remote set-url-- push [name] [newUrl]
Pull remote warehouse: $git pull [remoteName] [localBranchName]
Push remote warehouse: $git push [remoteName] [localBranchName]
* if you want to submit a local branch test to the remote repository as a master branch of the remote repository, or as another branch called test, as follows:
$git push origin test:master / / submit a local test branch as a remote master branch
$git push origin test:test / / submit a local test branch as a remote test branch
2) commands related to branch operation
View the local branch: $git branch
View remote branches: $git branch-r
Create a local branch: $git branch [name]-Note that the new branch will not automatically switch to the current branch after it is created
Switch branches: $git checkout [name]
Create a new branch and immediately switch to the new branch: $git checkout-b [name]
Delete branches: the $git branch-d [name]-d option can only delete branches that have already participated in the merge, and cannot be deleted for branches that have not been merged. If you want to force the deletion of a branch, use the-D option
Merge branch: $git merge [name]-merge the branch named [name] with the current branch
Create a remote branch (local branch push to remote): $git push origin [name]
Delete remote branch: $gitpush origin: heads/ [name] or $gitpush origin: [name]
* create an empty branch: (remember to submit changes to your current branch before executing the command, otherwise you will be forced to delete it without regret)
$git symbolic-ref HEAD refs/heads/ [name]
$rm .git / index
$git clean-fdx
3) tag operation related commands
View version: $git tag
Create version: $git tag [name]
Delete version: $git tag-d [name]
View the remote version: $git tag-r
Create a remote version (local version push to remote): $git push origin [name]
Delete the remote version: $git push origin: refs/tags/ [name]
Merge the tag of the remote warehouse into the local: $git pull origin-- tags
Upload local tag to remote repository: $git push origin-- tags
Create an annotated tag:$ git tag-a [name]-m 'yourMessage'
4) Operation commands related to sub-module (submodule)
Add submodules: $git submodule add [url] [path]
For example, $git submodule add git://github.com/soberh/ui-libs.git src/main/webapp/ui-libs
Initialization submodule: $git submodule init-run only once when the warehouse is checked out for the first time
Update sub-module: $git submodule update-each time you update or switch branches, you need to run it.
Delete sub-module: (4 steps)
1) $git rm-- cached [path]
2) Edit the ".gitmodules" file to delete the relevant configuration nodes of the sub-module
3) Edit the ".git / config" file to delete the relevant configuration nodes of the sub-module
4) manually delete the remaining directories of the sub-module
5) ignore some files and folders and do not submit
Create a file named ".gitignore" under the repository root, and write unwanted folder names or files, each element on a single line, as shown in
Target
Bin
* .db
Git common commands
Git branch view all local branches
Git status to view current status
Git commit submission
Git branch-a view all branches
Git branch-r view all local branches
Git commit-am "init" submit and comment
Git remote add origin git@192.168.1.119:ndshow
Git push origin master pushes files to the server
Git remote show origin displays the resources in the remote library origin
Git push origin master:develop
Git push origin master:hb-dev associates local libraries with libraries on the server
Git checkout-- track origin/dev switches to remote dev branch
Git branch-D master develop deletes the local library develop
Git checkout-b dev establishes a new local branch dev
Git merge origin/dev merges the branch dev with the current branch
Git checkout dev switches to local dev branch
Git remote show View remote Library
Git add.
Git rm file name (including path) removes the specified file from git
Git clone git://github.com/schacon/grit.git pulled the code from the server
Git config-- list looks at all users
Git ls-files, look at what has been submitted
Git rm [file name] Delete a file
Git commit-a submits all changes to the current repos
Git add [file name] add a file to git index
Git commit-v you can see the difference in commit when you use the-v parameter
Git commit-m "This is the message describing the commit" add commit information
Git commit-a-a stands for add, adding all the change to git index and then commit
Git commit-a-v general submit command
Git log, look at your commit's log.
Git diff to view updates that have not been temporarily saved
Git rm a.a removes files (removes from staging and workspaces)
Git rm-cached a.a removes files (only deleted from the staging area)
Git commit-m "remove" removes files (deleted from Git)
Git rm-f a.a forcibly remove modified files (deleted from staging and workspace)
Git diff-- cached or $git diff-- staged to view updates that have not been submitted
Git stash push gives the file to push to a temporary space
Git stash pop pop the file from the temporary space
Git remote add origin git@github.com:username/Hello-World.git
Git push origin master submits the local project to the server
Git pull synchronizes locally with the server
-
Git push (remote repository name) (branch name) pushes the local branch to the server.
Git push origin serverfix:awesomebranch
-
Git fetch is equivalent to getting the latest version from remote to local, and will not automatically merge
Git commit-a-m "log_message" (- a commits all changes,-m adds log information) local modifications are synchronized to the server:
Git branch branch_0.1 master creates a branch_0.1 branch from the main branch master
Git branch-m branch_0.1 branch_1.0 renamed branch_0.1 to branch_1.0
Git checkout branch_1.0/master switches to branch_1.0/master branch
Du-hs
Mkdir WebApp
Cd WebApp
Git init
Touch README
Git add README
Git commit-m 'first commit'
Git remote add origin git@github.com:daixu/WebApp.git
Git push-u origin master
At this point, the study on "what is the centralized operation command of Git in Linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.