下载

下载地址

git-scm.com

gitforwindows.org

安装(凡是下面没有给出图片的,都按默认选项就行)

选择安装组件

调整你的 path 环境变量

第一种是仅从 Git Bash 使用 Git。

第二种是从命令行以及第三方软件进行 Git。

第三种是从命令提示符使用 Git 和可选的 Unix 工具。

选择HTTPS后端传输

在具有企业管理证书的组织中要使用安全通道。一般都用第一个就OK了~

添加成功以后

推送本地代码到仓库示例以及报错解决

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved. Try the new cross-platform PowerShell https://aka.ms/pscore6 PS C:\jin_files\code\pwa\service_worker>
PS C:\jin_files\code\pwa\service_worker> git init
Initialized empty Git repository in C:/jin_files/code/pwa/service_worker/.git/
PS C:\jin_files\code\pwa\service_worker> git add README.md
On branch master Initial commit (use "git add <file>..." to include in what will be committed)
index.html nothing added to commit but untracked files present (use "git add" to track)
PS C:\jin_files\code\pwa\service_worker> git remote add origin https://gitee.com/tangdd369098655/service_worker.git
error: src refspec master does not match any
error: failed to push some refs to 'https://gitee.com/tangdd369098655/service_worker.git'
PS C:\jin_files\code\pwa\service_worker> git status
On branch master No commits yet Untracked files:
(use "git add <file>..." to include in what will be committed)
index.html nothing added to commit but untracked files present (use "git add" to track)
PS C:\jin_files\code\pwa\service_worker> git add index.html
PS C:\jin_files\code\pwa\service_worker> git status
On branch master No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: index.html PS C:\jin_files\code\pwa\service_worker> git commit -m "initial commit"
[master (root-commit) a9cdf97] initial commit
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 index.html
On branch master
PS C:\jin_files\code\pwa\service_worker> git push
fatal: The current branch master has no upstream branch. git push --set-upstream origin master PS C:\jin_files\code\pwa\service_worker> git remote origin
error: Unknown subcommand: origin
usage: git remote [-v | --verbose]
or: git remote add [-t <branch>] [-m <master>] [-f] [--tags | --no-tags] [--mirror=<fetch|push>] <name> <url>
or: git remote rename <old> <new>
or: git remote remove <name>
or: git remote set-head <name> (-a | --auto | -d | --delete | <branch>)
or: git remote [-v | --verbose] show [-n] <name>
or: git remote prune [-n | --dry-run] <name>
or: git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]
or: git remote set-branches [--add] <name> <branch>...
or: git remote get-url [--push] [--all] <name>
or: git remote set-url [--push] <name> <newurl> [<oldurl>]
or: git remote set-url --add <name> <newurl>
or: git remote set-url --delete <name> <url> -v, --verbose be verbose; must be placed before a subcommand PS C:\jin_files\code\pwa\service_worker> gie remote
gie : The term 'gie' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1
+ gie remote
+ ~~~
+ CategoryInfo : ObjectNotFound: (gie:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException PS C:\jin_files\code\pwa\service_worker> git remote
origin
PS C:\jin_files\code\pwa\service_worker> git remote -v
origin https://gitee.com/tangdd369098655/service_worker.git (fetch)
origin https://gitee.com/tangdd369098655/service_worker.git (push)
PS C:\jin_files\code\pwa\service_worker> git push --set-upstream origin master
info: detecting host provider for 'https://gitee.com/'...
warning: ----------------- SECURITY WARNING ----------------
warning: | TLS certificate verification has been disabled! |
warning: ---------------------------------------------------
warning: HTTPS connections may not be secure. See https://aka.ms/gcmcore-tlsverify for more information.
info: detecting host provider for 'https://gitee.com/'...
warning: ----------------- SECURITY WARNING ----------------
warning: | TLS certificate verification has been disabled! |
warning: ---------------------------------------------------
warning: HTTPS connections may not be secure. See https://aka.ms/gcmcore-tlsverify for more information.
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 218 bytes | 218.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.2]
To https://gitee.com/tangdd369098655/service_worker.git
* [new branch] master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
PS C:\jin_files\code\pwa\service_worker>

附录:Git 常用命令

初始化版本库,并提交到远程服务器端---名称为origin的远程服务器库

mkdir WebApp
cd WebApp
git init 本地初始化
touch README
git add README 添加文件
git commit -m 'first commit'
git remote add origin git@github.com:AAA/myCode.git
git branch 查看本地所有分支
git status 查看当前状态
git commit 提交
git branch -a 查看所有的分支
git branch -r 查看远程所有分支
git commit -am "init" 提交并且加注释
git push origin master 将文件给推到服务器上
git remote show origin 显示远程库origin里的资源
git push origin master:develop
git push origin master:hb-dev 将本地库与服务器上的库进行关联
git checkout --track origin/dev 切换到远程dev分支
git branch -D master develop 删除本地库develop
git checkout -b dev 建立一个新的本地分支dev
git merge origin/dev 将分支dev与当前分支进行合并
git checkout dev 切换到本地dev分支
git remote show 查看远程库
git rm 文件名(包括路径) 从git中删除指定文件
git clone git://github.com/aaa/aaaa.git 从服务器上将代码给拉下来
git config --list 看所有用户
git ls-files 看已经被提交的
git rm [file name] 删除一个文件
git commit -a 提交当前repos的所有的改变
git add [file name] 添加一个文件到git index
git commit -v 当你用-v参数的时候可以看commit的差异
git commit -m "This is the message describing the commit" 添加commit信息
git commit -a -a是代表add,把所有的change加到git index里然后再commit
git commit -a -v 一般提交命令
git log 看你commit的日志
git diff 查看尚未暂存的更新
git rm a.a 移除文件(从暂存区和工作区中删除)
git rm --cached a.a 移除文件(只从暂存区中删除)
git commit -m "remove" 移除文件(从Git中删除)
git rm -f a.a 强行移除修改后文件(从暂存区和工作区中删除)
git diff --cached 或 $ git diff --staged 查看尚未提交的更新
git remote add origin git@github.com:username/Hello-World.git
git push origin master 将本地项目给提交到服务器中
git pull 本地与服务器端同步
git push (远程仓库名) (分支名) 将本地分支推送到服务器上去。
git push origin serverfix:awesomebranch
git fetch 相当于是从远程获取最新版本到本地,不会自动merge
git commit -a -m "log_message" (-a是提交所有改动,-m是加入log信息) 本地修改同步至服务器端 :
git branch branch_0.1 master 从主分支master创建branch_0.1分支
git branch -m branch_0.1 branch_1.0 将branch_0.1重命名为branch_1.0
git checkout branch_1.0/master 切换到branch_1.0/master分支
du -hs
git branch 删除远程branch
git push origin :branch_remote_name
git branch -r -d branch_remote_name

忽略某个文件夹

如果已经提交过的文件或者文件夹怎么办?此时更改.gitignore文件对已经提交的文件是无效的

编辑.gitignore文件。
然后如果是单个文件,可以使用如下命令从仓库中删除:
git rm --cached logs/xx.log
如果是整个目录:
git rm --cached -r logs
如果文件很多,那么直接
git rm --cached -r .
如果提示某个文件无法忽略,可以添加-f参数强制忽略。
git rm -f --cached logs/xx.log
然后
git add .
git commit -m "Update .gitignore"

使用.gitignore忽略文件或者文件夹参考来源 https://blog.csdn.net/toopoo/article/details/88660806

常用命令部分参考来源 https://www.cnblogs.com/kenshinobiy/p/4543976.html

GIT安装步骤记录以及Git 常用命令,忽略文件,推送本地代码到仓库示例以及报错解决的更多相关文章

  1. NO.A.0006——Git在IntelliJ IDEA中的使用/创建项目并推送到GitHub仓库/分支管理及分支合并

    一.在IntelliJ IDEA中使用Git: 1.在IDEA下创建项目并编写一个main方法的工程: 在IDEA下新建一个Project IDEA-->新建一个Project-->Fil ...

  2. Git学习——把文件推送到远程仓库

    本地仓库与GitHub仓库关联 git remote add origin git@github.com:<github账户名>/<github的仓库名>.git 把本地库的所 ...

  3. Git - Git推送本地分支到远程分支报错(! [rejected] non-fast-forward)的解决办法

    一般都是冲突造成的,解决方案执行如下命令(dev为分支名称): git fetch origin dev  #获取远程 dev 分支的修改 git merge origin dev       #合并 ...

  4. 使用tortoise git将一个现有项目推送到远程仓库

    一.安装文件: 1.git https://git-scm.com/downloads 2.tortoise git https://tortoisegit.org/download/ 二.将一个现有 ...

  5. git常用命令以及如何与fork别人的仓库保持同步

    简单常用命令1.git status查看当前仓库是否有文件改动a:提示Your branch is up-to-date with 'origin/master'.nothing to commit, ...

  6. 使用git命令将本地项目推送到远程仓库

    将本地项目推送到远程仓库 这里先放一张图, 有助于理解git命令 1. 在GitHub上新建一个仓库 注意不要勾选自动生成README.md文件, 否则会产生某些问题, README.md文件到时可以 ...

  7. git将本地仓库推送到远程仓库

    如何将本地仓库推送到公司远程仓库? 1:前提是你本地安装好git.先把远程git仓库克隆到本地  git clone 远程仓库的地址(SSH) 2: git  branch //查看本地分支 3: g ...

  8. 如何将git本地创建的项目推送到github仓库

    除了集中式的版本控制系统CVS和SVN外,还有目前世界上最先进的分布式版本控制系统Git,它的创始人是创建了linux的大神 - linus.GitHub网站与2008年开始服役,为开源项目免费提供G ...

  9. Win10 pip安装pycocotools报错解决方法(cl: 命令行 error D8021 :无效的数值参数“/Wno-cpp”)

    参考: https://blog.csdn.net/chixia1785/article/details/80040172 https://blog.csdn.net/gxiaoyaya/articl ...

  10. Git本地初始化并推送到远程仓库

    git常用命令 1.全局配置git用户名邮箱 git config --global user.name '你的名字' git config --global user.email '你的邮箱地址' ...

随机推荐

  1. Linux软件安装方式 - Tarball&RPM&YUM

    软件安装 简介 概念详解 # 概念详解 - 开放源码: 程序码, 写给人类看的程序语言, 但机器并不认识, 所以无法执行; - 编译器: 将程序码转译成为机器看的懂得语言, 就类似翻译者的角色; - ...

  2. Excel中的VLOOKUP函数

    VLOOKUP函数是Excel中的一个纵向查找函数,功能是按列查找,最终返回该列所需查询序列所对应的值. 该函数的语法规则如下: VLOOKUP(lookup_value,table_array,co ...

  3. 第2-3-1章 文件存储服务系统-nginx/fastDFS/minio/阿里云oss/七牛云oss

    目录 文件存储服务 1. 需求背景 2. 核心功能 3. 存储策略 3.1 本地存储 3.2 FastDFS存储 3.3 云存储 3.4 minio 4. 技术设计 文件存储服务 全套代码及资料全部完 ...

  4. 如何正确遵守 Python 代码规范

    前言 无规矩不成方圆,代码亦是如此,本篇文章将会介绍一些自己做项目时遵守的较为常用的 Python 代码规范. 命名 大小写 模块名写法: module_name 包名写法: package_name ...

  5. 修复 docker build 错误 "ERROR: No build stage in current context"

    若 docker build 时遇到了错误 "ERROR: No build stage in current context",则有可能是没有将 FROM 命令语句放置在第一行. ...

  6. hwlog----hwlog_adaptor.go

    // Copyright(c) 2021. Huawei Technologies Co.,Ltd. All rights reserved.// Package hwlog provides the ...

  7. Python调用golang

    有些时候因为效率问题部分代码会 使用Python调用go的编译生成动态链接库go 代码示例//add.gopackage main import "C" //export Addf ...

  8. Atcoder补题计划

    11.17 AtCoder Regular Contest 151 知识点: A:简单题 B:计数,并查集 补题传送门

  9. 基于k8s的CI/CD的实现

    综述 首先,本篇文章所介绍的内容,已经有完整的实现,可以参考这里. 在微服务.DevOps和云平台流行的当下,使用一个高效的持续集成工具也是一个非常重要的事情.虽然市面上目前已经存在了比较成熟的自动化 ...

  10. 解决Anaconda关联VSCode使用conda运行Python报错(无法将“conda”项识别为 cmdlet、函数、脚本文件或可运行程序)

    错误 刚安装好Anaconda之后创建好VS Code环境运行Python会报错,但是仍然是可以正常运行,强迫症想解决报错 PS C:\Users\Satan\Documents\Code\Pytho ...