git - weliame/MyDoc GitHub Wiki

Update your fork with the forked repo

git remote add upstream [email protected]
git fetch upstream
git merge upstream/master master

Push init local repo to remote repo

git remote add origin http://giturl.of.youself

Get current remote url and remote branch

git remote show origin

Configure remote url

git remote set-url origin http://newgiturl.of.youself

Create a new local branch base on a remote branch

git checkout -b abranch origin/abranch

Set up current branch to track remote branch abranch from origin

git branch -u origin/abranch

Delete remote branch

git push origin :your_branch_name

Delete remote branch

git push origin --delete d_new_front_partner

Ignore committed file’s modification

git update-index --assume-unchanged filename

Basic push and pull

git pull origin yqwu   

git push origin yqwu

git checkout abranch

Merge master to abranch

git checkout abranch

git merge master  

Show recent commit summary

git show

Show log about the id

git show commit_id

Show all files about a commit

git show --pretty="format:" --name-only commit_id

Show all commit summary

git log

Show log of each commit and it’s committed message

git log --pretty=oneline (oneline,short,full,fuller)

Show log of each commit message and committed files

git log —-stat

Show log as formatter

git log --pretty=format:"%h - %an, %ar : %s”

Show committed tree

git log --pretty=format:"%h %s" -—graph

Git Diff

git diff master dev filename # compare the filename in master and dev branch, master as source, filename in dev is the new one

Check out specify file from other local branch

git checkout master -- filepath

Exclude local file

If you ever want to ignore a file from git, but don't want to add it to the .gitignore file, you can do it on your local copy by adding it to the file ".git/info/exclude"

Setup an alias to do so, just add this to your .gitconfig file under the [alias] section

[alias]
exclude = !sh -c 'echo "$1" >> .git/info/exclude' -

Then you can execute:

git exclude SOME_FILE
⚠️ **GitHub.com Fallback** ⚠️