下载

下载地址

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. Jquery中Trigger()方法

    1. $(selector).trigger(event,[param1,param2,...]) 方法触发被选元素标签的指定事件类型 为元素边赋值为true,并触发元素标签的change方法 $(' ...

  2. idea如何生成jar包

    最近在研究RMI反序列化命令执行的漏洞,让我这个java新手吃尽了苦头,能多学习一些是一些吧. 记录一下写好的java文件生成jar包的过程. 环境: Win10,jdk1.7, idea2016.2 ...

  3. adb 安装与使用

    什么是adb adb 是有个通用命令行工具 他允许您与模拟器实例或者链接的Android设备进行通信,他可为各种设备操作提供便利,比如安装和调试应用 启动adb 服务在命令行中输入adb start- ...

  4. JVM学习笔记——类加载和字节码技术篇

    JVM学习笔记--类加载和字节码技术篇 在本系列内容中我们会对JVM做一个系统的学习,本片将会介绍JVM的类加载和字节码技术部分 我们会分为以下几部分进行介绍: 类文件结构 字节码指令 编译期处理 类 ...

  5. 2022icpc新疆省赛

    菜鸡第一次打icpc 记录一下历程 习惯#define int long long 以下皆是按照我认为的难易顺序排序 K. 看题意大概就是说求从L加到R 1 ios::sync_with_stdio( ...

  6. hadoop配置day01

    hadoop 安装jdk 配置文件: sudo vim /etc/profile 配置文件: export JAVA_HOME=/home/hadoop/jvm/jdk1.8.0_341 export ...

  7. 第2-2-4章 常见组件与中台化-常用组件服务介绍-分布式ID-附Snowflake雪花算法的代码实现

    目录 2.3 分布式ID 2.3.1 功能概述 2.3.2 应用场景 2.3.3 使用说明 2.3.4 项目截图 2.3.5 Snowflake雪花算法的代码实现 2.3 分布式ID 2.3.1 功能 ...

  8. C#读写锁ReaderWriteLockSlim的使用

    C#读写锁ReaderWriterLockSlim的使用 using System; using System.Collections.Generic; using System.Linq; usin ...

  9. 核磁共振成像学习笔记——从FID信号到K空间

    在理想磁场环境下(没有不存在场不均匀性),对于一个没有梯度场的方块. 此时,RF pulse的两路正交信号(相位差为90°)对此方块进行激发,然后收取信号,我们可以得到由此方块产生的FID信号. 设此 ...

  10. vue 中使用 this 更新数据的一次大坑

    情景说明: 之前用 vue 做数据绑定更新时,发现一个莫名奇妙的问题. 我在 vue 实例中声明了一个数组属性如 books: [],在异步请求的回调函数中使用 this.books = res.da ...