Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # clean up your local tracking branches for remote branches that have been deleted
- git fetch --prune
- # If you want only the remote URL, or if your are not connected to a network that can reach the remote repo:
- git config --get remote.origin.url
- # change the URI (URL) for a remote Git repository
- git remote set-url origin new.git.url/here
- # untuk cek
- git remote -v
- # config user email
- git config --global user.name "John Doe"
- git config --global user.email johndoe@example.com
- # You can view all of your settings and where they are coming from using:
- git config --list --show-origin
- git config --list
- git config user.name
- # remove entry git config global
- git config --global --unset core.excludesfile
- # edit langsung ke file config global
- git config --global --edit
- # When using git clone (from GitHub, or any source repository for that matter) the default name for the source of the clone is "origin".
- # Using git remote show will display the information about this remote name.
- # If you require full output and you are on a network that can reach the remote repo where the origin resides :
- git remote show origin
- # update working Git branch from another branch (develop)
- git checkout feature1
- git merge develop
- # Cleaning Ignored Files
- git rm -r --cached .
- git add .
- git commit -m "Clean up ignored files"
- # How to undo the last commit in git
- git reset HEAD^
- # If you want to revert a change that you have committed, do this:
- git revert <commit 1> <commit 2>
- # unstage all files you might have staged with git add:
- git reset
- # melihat diff setelah add (staged)
- # --cached means show the changes in the cache/index (i.e. staged changes) against the current HEAD.
- # --staged is a synonym for --cached.
- git diff --cached <nama file optional>
- # revert all local uncommitted changes (should be executed in repo root):
- git checkout .
- # revert all local uncommitted changes (longer to type, but works from any subdirectory)
- git reset --hard HEAD
- # atau stash (lebih aman) undo all uncommitted or unsaved changes
- git add . (adding everything)
- git stash
- git stash drop
- # revert uncommitted changes only to particular file or directory:
- git checkout [some_dir|file.txt]
- # remove all local untracked files, so only git tracked files remain:
- # WARNING: -x will also remove all ignored files, including ones specified by .gitignore!
- # You may want to use -n for preview of files to be deleted.
- git clean -fdx
- # note: use the -n option to see which files will be deleted. jika yakin gunakan -f
- # force “git pull” to overwrite local files with remote files
- git checkout development
- git fetch --all
- git reset --hard origin/development
- # executing commands below is basically equivalent to fresh git clone from original source
- # (but it does not re-download anything, so is much faster):
- git reset
- git checkout .
- git clean -fdx
- # If you want to revert changes made to your working copy, do this:
- git checkout .
- # If you want to revert changes made to the index (i.e., that you have added), do this.
- # Warning this will reset all of your unpushed commits to master!:
- git reset
- # Or untracked directories (e.g., new or automatically generated directories):
- git clean -fd
- # menambahkan tag
- git tag <tagname>
- # add with annotation
- git tag -a <tagname> -m "some message"
- # push single tag
- git push origin <tag_name>
- # push bulk tag
- git push origin --tags
- # melihat tampilan berapa log terakhir, misal 5
- git log -n <number-of-commits> --pretty=short
- # jika ingin tampil satu baris
- git log -n <number-of-commits> --pretty=oneline
- # melihat log perubahan file di commit mana aja, contoh:
- git whatchanged fuel/app/classes/controller/cpegawai.php
- # melihat perubahan dalam commit
- git show 8d180725a79315fc1beba7f6caaf95372595bca9
- git show 8d180725a79315fc1beba7f6caaf95372595bca9 --name-only
- git show --color --pretty=format:%b 8d180725a79315fc1beba7f6caaf95372595bca9
- # melihat log siapa yang commit, kapan commit, file apa aja yg di-commit
- git log --stat -n 10 --name-only
- # Use git log to view the commit history.
- # export diff antara 2 commit ke file txt
- git diff 3b1b3edfce62866b57b6f615b6e440b80025df97(sebelum) 33ef428468851e38ff1db232179ea9c20cf1aa6f(sesudah) > d:/temporary/diff.txt
- # melihat file apa aja yang berubah antara commit
- git diff --stat --diff-filter=ACRM --name-only f1f9ffa6439049d648dce5cc7538d06a1fbf1bb9 19eadcbaf35910c7b1345735e6bca4f6da11d5f8
- # archive diff antara 2 commit ke file zip
- git archive --output=d:/temporary/diff.zip HEAD $(git diff --stat --diff-filter=ACRM --name-only f1f9ffa6439049d648dce5cc7538d06a1fbf1bb9 19eadcbaf35910c7b1345735e6bca4f6da11d5f8)
- # GET FILES BETWEEN TWO COMMIT WHICH WAS CHANGED OR NEW CREATE
- git archive --format=zip --output=d:/temporary/files.zip HEAD $(git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT HEAD)
- git archive --output=d:/temporary/files.tar HEAD $(git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT HEAD)
- # If you want to get an overview over all the differences that happened from commit to commit,
- # use git log or git whatchanged with the patch option:
- # include patch displays in the commit history (termasuk menampilkan baris perubahannya)
- git log -p
- git whatchanged -p
- # contoh lihat hanya 1 file
- git log -p fuel/app/classes/controller/cpegawai.php
- # only get history of those commits that touch specified paths (hanya menampilkan berubah dicommit apa aja)
- git log path/a path/b
- git whatchanged path/c path/d
- # How to remove git files, directories in .gitignore from a remote repository
- # Step 1: Unstage the files/directory
- git rm -r --cached src/environments/environment.ts
- git rm -r --cached src/environments/environment.prod.ts
- # Step 2: Make new commit
- git commit -am "Remove ignored file"
- # Step 3: Push changes to remote git repository
- git push origin bugfix
- # alias
- git config --global alias.co checkout
Add Comment
Please, Sign In to add comment