Oschina version management tool git tutorial

Git global settings:

git config --global user.name "aming"
git config --global user.email "[email protected]"


Create a git repository

mkdir crawler-framework
cd crawler-framework
git init
touch README
git add README
git commit -m "first commit"
git remote add origin http://git.oschina.net/aming0502/crawler-framework.git
git push -u origin master


Already have a project?

cd existing_git_repo
git remote add origin http://git.oschina.net/aming0502/crawler-framework.git
git push -u origin master


Solution when there is a conflict between git and the repository:
first execute the following pull action, and then execute the push action

or
git push -u origin master -f


The settings for git to ignore certain files Create a .gitignore file
in the project root directory.

There are two modes for gitignore file filtering, open mode and conservative mode. The

open mode is responsible for setting which files and folders to filter, eg:

filter folder settings:

/mtk/ means to filter this folder
Filter file settings


Specify to filter certain types of files:
*.zip
*.rar
*.via
*.tmp
*.err

Specify to filter a file:

/mtk/do.c
/mtk/if.h

Conservative mode is responsible for setting which files are not filtered, that is, which files are to be tracked. Track a certain folder

! /plutommi/mmi
Track a certain type of file

!*.c
!*.h

track a specific file

!/plutommi/mmi/mmi_features.h

Simple principles for configuring .gitignore

Use a combination of shared mode and conservative mode to configure. eg: There are many folders and files in a folder, and I only want to track one of the files, so the setting can satisfy this situation, first use the shared mode to set the entire directory to not track, and then use the conservative mode Set the files you want to track in this folder to be tracked, the configuration is very simple, you can track the files you want to track.


# Delete untracked files
git clean -f

# Even the untracked directory is also deleted
git clean -fd

# Even the untrack files/directories of gitignore are also deleted (use with caution, generally this is used to delete the compiled .o Class files)
git clean -xfd

# Before using the above git clean, it is recommended to add the -n parameter to see which files will be deleted to prevent important files from being deleted by mistake
git clean -nxfd
git clean -nf
git clean -nfd

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326798402&siteId=291194637