git详细教程(git操作教程)

git详细教程(git操作教程)命令 描述 Local Repository sudo apt get install git Install git in Linux Ubuntu git config global user name alice Set username as alice git config global user email Set email as

大家好,我是讯享网,很高兴认识大家。

 命令 描述 Local Repository sudo apt-get install git Install git in Linux Ubuntu git config –global user.name alice Set username as ‘alice’ git config –global user.email Set email as ‘ git config –global core.editor “vim” Set ‘vim’ as default text-editor git config –global credential.helper cache Cache username and password git init Initialize git repository git status File status i.e. modified and untracked etc. git add . Add all untracked files git add -u Add all tracked files and ignore untracked git add file1 file2 Add (stage) file1 and file2 git rm –cached file1 Remove the staged file file1 git commit -m “commit message” Commit stage file with ‘commit message’ git log Show detail list of commits git log –oneline Show hash and commit name only git log –graph Show commits in the form of graph git log –oneline –graph Show online-commit in the form of graph git diff Differences between unstaged files and previous commit git diff –cached Differences between staged files and git diff –stat Show only changed filenames (not the details) git reset Remove all files from stage list (i.e. back to modified) git reset file1 Remove file1 from stage list (i.e. back to modified) git reset –hard 13802e3 Reset to previous commit with hash 13802e3 git reset HEAD –hard remove all changes after last commit git reset –merge (git merge –abort) abort current merge, without losing commits git reset HEAD~1 –soft abort current commit, without losing the changes git checkout file1 Remove changes from non-staged file1 to previous commit git rm file1 Delete file1 from git (but available in previous commit git mv file1 file2 rename file1 to file2 git branch Show all the branches git branch branch1 Create branch1 git branch -d branch1 Delete branch1 git checkout branch1 Go to branch1 git checkout master Go to master branch git merge branch1 Merge the brach1 to current branch e.g. master git checkout 13802e3 Create new branch from previous commit 13802e3 git checkout -b branch1 First checkout and then create branch Remote repository git remote add repoName https://url_of_repo Add remote repo with name ‘repoName’ git remote -v Show list of added repoNames git remote set-url origin git@{new_repo_name}.git change remote repo url to track git remote remove repoName Remove repoName from list git push repoName branch1 Push ‘branch1’ to ‘repoName’ git push repoName –all Push all branches to repoName git clone https://nameOfRemoteRepository Clone or download remote repository git clone –depth 1 https://nameOfRemoteRepository Clone only last branch git pull repoName branchName Download and merge ‘branchName’ of repoName git fetch repoName branchName Download, but not merge repoName git push origin –delete branchName Delete remote branch


讯享网

小讯
上一篇 2025-04-22 10:41
下一篇 2025-04-20 08:58

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/188792.html