Karena saya pengguna Git yang aktif, tentunya saya harus hafal perintah untuk mengoperasikannya. Sayangnya, yang saya hafal hanya clone, add, commit, dan push. Selain itu saya tidak hafal, maka dari itu saya buat catatan ini untuk memudahkan saya mengingat berbagai perintah dalam Git yang umum di gunakan.
Commit changes you want to keep. If you want to take over any of the changes you made in detached HEAD state, commit them. Like:
Discard changes you do not want to keep. The hard reset will discard any uncommitted changes that you made in detached HEAD state:
Check out your branch. Exit detached HEAD state by checking out the branch you worked on before, for example:
Take over your commits. You can now take over the commits you made in detached HEAD state by cherry-picking, as shown in my answer to another question.
Sekian, terimakasih.
Sumber:
Setup and Config
Globalgit config --global user.email "your_email@example.com"
git config --global user.name "Em Suryadi"
Current repositorygit config user.email "your_email@example.com"
git config user.name "Em Suryadi"
Getting and Creating Projects
Init repositorygit init
Clone repository from remote servergit clone https://server.com/project-name/project.git
Basic Snapshotting
Pull repository from remote servergit pull origin
Addgit add .
#atau
git add --all
Statusgit status
Diffgit diff
Commitgit commit -m "commit title"
Push to remote servergit push origin
Clear index cache and retrackgit rm -r --cached .
Submodules
Add submodule from remote servergit submodule [--quiet] add [<options>] [--] <repository> [<path>]
Init submodule from remote servergit submodule [--quiet] add [<options>] [--] <repository> [<path>]
Update submodule from remote servergit submodule [--quiet] update [<options>] [--] [<path>…]
SNIPPET:
How to exit (“fix”) detached HEAD state when you already changed something in this mode and want to save your changes. (That part is optional though.)Commit changes you want to keep. If you want to take over any of the changes you made in detached HEAD state, commit them. Like:
git commit -a -m "your commit message"
Discard changes you do not want to keep. The hard reset will discard any uncommitted changes that you made in detached HEAD state:
git reset --hard
(Without this, step 3 would fail, complaining about modified uncommitted files in the detached HEAD.)Check out your branch. Exit detached HEAD state by checking out the branch you worked on before, for example:
git checkout master
Take over your commits. You can now take over the commits you made in detached HEAD state by cherry-picking, as shown in my answer to another question.
git reflog
git cherry-pick (hash1) (hash2) ...
Sekian, terimakasih.
Sumber:
Tidak ada komentar:
Posting Komentar