Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Friday, October 1, 2021

Immediate Git Commands

a list of handy git commands

# check the change of the file 

git diff filename

# check in parital change of the file -p flag will show us the change in patch level

git add -p filename

# use git commit to enter the concise message

git commit 

# use git log to check the commit history to ensure the change had been commit

git log

# create a branch   

git branch test

# use the branch

git checkout test

# push the change back to the repository

git push --set-upstream origin test

# merge the change

git merge test

# undo the merge and rebase

git merge --abort

git rebase--abort

#use mergetool to perform the merge

git mergetool




Monday, September 6, 2021

how to add a list of empty folders to github in windows environment?

When we setup the project structure in the development. the Github have prevent us to push all empty folder to the GitHub Repository in remote server. we can use gitkeep utility in the Macs and Linux environmen to create gitkeep for those blank folder. we cannot gitkeep in the Windows environment. but there is a work around. we can use the powershell scripts to loop through all subfolders under the current project folder and add .gitkeep file in each empty folder. then we can upload those folders to the server.

here is the code to be execute in the windows PowerShell ISE, you should copy it to your windows PowerSehll ISE and replace {Your Current Project Folder path} with your own folder path

Get-ChildItem '{Your Current Project Folder path}' -Recurse -Directory | 

Where-Object {[System.IO.Directory]::GetFileSystemEntries($_.FullName).Count -eq 0} | 

ForEach-Object { New-Item ($_.FullName + "\.gitkeep") -ItemType file}




Sunday, July 18, 2021

how to ensure the push of modification from local to GitHub always execute?

 Usually I only use the following commands to check in the change to github.

git add . //add the change in the staging area

git commit -m "commit"  //add the change to the local repository

git push //to check in the change to GitHub

Some times it is weird, I discovered that new files were check into the remote repository, the modified files still kept in the local repository.

It is better to use this command to check into the remote repository with force flag to ensure the change should be upload from local to remote repository.

git push --set-upstream origin master -f 

Friday, March 27, 2020

Handy Command for GitHub

i just organized a list of GitHub command, i hope this will help you speed up the GitHub adaption


-git init : create repository
-git status: Compare working directory, staging area and current branch
-git add: add changes to staging area
-git commit: Commit changes from staging to current branch
-git log: show history of project commits
-git branch -c : Create a new branch1
-git checkout: check out switch to a branch
-git branch: List branches
-git checkout: check out a branch (update HEAD)
-git checkout -b: Create branch, then check it out
-git stash: Stash changes from working directory
-git stash list: List stashes
-git stash pop: apply stashed changes to working directory.
-git branch -v: list latest version of changes in each branch
-git branch -d: delete a branch
-git -am: git add commit within one line
-git merge: Merge changes from different branches


- git log: Show history of project commit
- git log <ref>: show history of pro commit prior to <ref>
- git log -all: show all commits
- git log --author <string> : show commits with matching author
- git log --since <date>: show commits since date
- git log --until <date>: show commits prior to date
- git show: show a single commit
- git diff: show the difference between commits, working directory and the staging area.
- git diff <commit> show diff between working direct and commit.
- git diff <commitA>..<commitB>: Diff between commit
- git diff <refA>..<refB>: Diff between ref(branches, et, al.)
- git log --oneline: show one commit per line
- git log --graph: show graph view of commits
- git show <commit>: show difference introduced by commit

- git diff --cached: Diff between staging area and HEAD

- git remote add : Add a new at
- git remote -v: List remote repositories
- git push -u : Push to , and set default upstream for
- git fetch: Fetch changes from remote repository
- git pull: Fetch, and then merge



git merge: merge changes from different branches
git merge --abort: abort an in process merge
git log branch1..branch2: log of commit in branch2 but not in branch1
git log branch1...branch2: log of commit in either branch but not both.
git merge --no-commit no-off: attempt to merge, but od not create an auto merge or ff merge
git branch --no-merged branch1: List branches that have unmerged commits
git branch --merged branch1: list branches that have no unmerged commits

Thursday, February 20, 2020

how to fix commit issue "fatal: unable to auto-detect email address (got 'danny@cc-fe053af4-868f6d6c9-brgtr.(none)')" against the Github?

i have a simple action to make a commit against Github

git init -- to initialize the local repository

git add .  --to check in the change in the local

git commit -m "my comment"

then i got an error


*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'danny@cc-fe053af4-868f6d6c9-brgtr.(none)')


the easy and straightforward solution is manually add user section in the config file in .git folder.


[user]
name=github username
email=email for github login