The file .gitignore is use to determine which files will not be included in the version control of a folder.
Here are common commands on git
Add files to local repository
To create a local git. Change to the folder containing the source codes or create a new folder.git init
Copy projects from github repository. Here we copy framework7 to a localfolder f7example
git clone https://github.com/tboxmy/helloworld.git example
Copy with a username
git clone https://tboxmy@github.com/tboxmy/helloworld.git example
Add filenames to queue files for version control.
git add helloworld.html
Add all filenames for version control
git add --all
Display status of changes and which branch is being used.
git status
Apply the files to the repository.
git commit -m "These are the initial files"
Check user settings
git config --list
git config user.name
Edit your username and email settings
git config --global user.name tboxmy
git config --global user.email tboxmy@gmail.com
Display current log
git log --decorate
git log --pretty=format:"%h - %an, %ar : %s"
git log --after="2018-01-2T17:08:30+0800" \
--before="2018-02-2T17:08:30+0800" --pretty=fuller
Limit log to the last 2 entries
git log --decorate -2
To view changes between files and in the version control. There are several options available
git diff
git diff --staged
git diff --cached
git diff --stat
Working on Branch
To create a new branchgit branch somethingnew
Switch to that branch
git checkout somethingnew
Or create a new branch while switching to the new branch
git checkout -b somethingnew
Merge changes to the Master branch
git checkout master
git merge somethingnew
Delete a branch
git branch -d somethingnew
Editing a file
Edit a file from the queue. This file have not been made to commit into the repository.git reset HEAD helloworld.html
Reset file back to the previous version in queue.
git checkout helloworld.html
Remote repositories
List remote repositoriesgit remote -v
Display remote in use
git remote
git remote show origin
Add a remote repository
git remote add helloworld git:github.com/tboxmy/hello.git
Retrieve files from remote repository
git remote -v
git fetch helloworld
Send files to remote repository. Need to specify the remote name and a branch
git push origin master
No comments:
Post a Comment