Git本地项目开发流程记录

本文介绍了在GitBash中进行本地项目开发的基础流程,包括工作区、缓存区和版本区的概念,以及如何初始化项目、管理分支、查看日志、进行版本操作和配置Gitignore。还分享了Git的一些实用技巧和配置方法。
摘要由CSDN通过智能技术生成
  1. 背景
    基于Git Bash本地创建项目,了解Git项目开发的基本流程,便于管理和记录算法开发流程,规范代码结构。
  2. 相关概念
    Git分区:工作区,缓存区,版本区。工作区即代码开发的本地文件,缓存区为使用Git add后添加到Git缓存的文件,版本区指使用Git commit添加到仓库的文件。
  3. 项目开发
    初始化项目工作区:git init
    添加文件到缓存区:git add filename (添加所有文件:git add .)
    添加备注信息到版本区:git commit -m “commit info”
    状态查询(查看分支是否更新完成):git status
    (可选的:版本区打标:git tag)
  4. 项目管理
    1. 分支管理
    创建分支:git checkout branchname
    合并分支(branch2合并到branch1): (branch1) git merge branch2
    删除分支(在其他分支删除branch2): (branch1) git checkouot -d branch2
    2. 日志管理
    查看日志:git log
    3. 版本管理
    版本标签:git tag n.m.k
  5. Git技巧
    1. 只存储关键代码,删除不必要的文件: .gitignore配置可忽略文件(如删除.txt: .txt, 删除根目录下x文件夹:/x/)
    2. 从特定tag下创建分支:git checkout -b branchname version
    3. 更新git缓存的.gitignore文件:git rm --cached filename
  6. 其他
    1. git bash vim配置,支持python,c, c++头文件标头
    autocmd BufNewFile *.cpp,*.py,*.[ch],*.sh,*.java exec ":call SetTitle()" 
    func SetTitle() 
        if &filetype == 'sh' 
            call setline(1,"\#########################################################################") 
            call append(line("."), "\# File Name:".expand("%")) 
            call append(line(".")+1, "\# Author:Xwell") 
            call append(line(".")+2, "\# mail:Xwell@qq.com") 
            call append(line(".")+3, "\# Created Time:".strftime("%Y-%m-%d %H:%M")) 
            call append(line(".")+4, "\#########################################################################") 
            call append(line(".")+5, "\#!/bin/bash") 
            call append(line(".")+6, "") 
        else 
            if &filetype == 'python'
                call setline(1,"\#########################################################################") 
                call append(line("."), "\# File Name:".expand("%")) 
                call append(line(".")+1, "\# Author:Xwell") 
                call append(line(".")+2, "\# mail:Xwell@qq.com") 
                call append(line(".")+3, "\# Created Time:".strftime("%Y-%m-%d %H:%M")) 
                call append(line(".")+4, "\#########################################################################") 
                call append(line(".")+5, "\#!/usr/bin/python") 
                call append(line(".")+6, "")
            endif
            if &filetype == 'cpp'
                call setline(1, "/*************************************************************************") 
                call append(line("."), "\* @Filename         : ".expand("%")) 
                call append(line(".")+1, "\* @Description      : ") 
                call append(line(".")+2, "\* @Date             : ".strftime("%Y-%m-%d %H:%M")) 
                call append(line(".")+3, "\* @Author           : Xwell")
                call append(line(".")+4, "\* @Email            : xxxxxx@qq.com")
                call append(line(".")+5, "\* @Vesion           : 1.0")
                call append(line(".")+6, "\* @ Copyright (c) 2024 Xwell. All rights reserved")
                call append(line(".")+7, "\* ************************************************************************/") 
                call append(line(".")+8, "")
                call append(line(".")+9, "#include<iostream>")
                call append(line(".")+10, "using namespace std;")
                call append(line(".")+11, "")
                call append(line(".")+12, "int main(int argc, char* argv[]){")
                call append(line(".")+13, "    return 0;")
                call append(line(".")+14, "}")
            endif
    
            if &filetype == 'c'
                call setline(1, "/*************************************************************************") 
                call append(line("."), "\* @Filename         : ".expand("%")) 
                call append(line(".")+1, "\* @Description      : ") 
                call append(line(".")+2, "\* @Date             : ".strftime("%Y-%m-%d %H:%M")) 
                call append(line(".")+3, "\* @Author           : Xwell")
                call append(line(".")+4, "\* @Email            : Xwell@qq.com")
                call append(line(".")+5, "\* @Vesion           : 1.0")
                call append(line(".")+6, "\* @ Copyright (c) 2024 Xwell. All rights reserved")
                call append(line(".")+7, "\* ************************************************************************/") 
                call append(line(".")+8, "")
                call append(line(".")+9, "#include<stdio.h>")
                call append(line(".")+10, "")
            endif
    
        endif
        autocmd BufNewFile * normal G
    endfunc 
    
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值