-
Notifications
You must be signed in to change notification settings - Fork 5
git it got it good
to turn any directory into a git repo run the following command within the directory
git initto remove git from a directory / project, just delete the .git directory in the root of the project.
to add a remote repo for a git project
git remote add origin <URL>to display the remote URLβs of a git project
git remote -vto copy a remote git repo to a local box run the below command
git clone <URL>to stage all the changes displayed from git status run the below command
git add .or
git add -Ato commit all the changes for a push to the remote repo run the below command
git commit -m βCommit local changesβto push all the committed changes to a remote repo run the below commandto push all the committed changes to a remote repo run the below command
git pushgit pull is a shortcut of two other git commands
git fetch
git merge
git fetch; git mergeto create a new branch that isolates a feature / fix run the below command
git branch new-featureto display all the branches of a git repo run the below command
git branchto switch to the new-feature branch run the below command
git checkout new-featureto create a new branch and switch to it run the below command
git checkout -b new-feature2to switch to the last checked out branch run the below command
git checkout -will switch back to the master branch
to combine the new-feature branch with master run the below commands
git checkout master
git merge new-featureto delete a branch after everything is complete with it, run the below command
git branch -d new-featureA merge conflict arises when the local and remote code both change, and it canβt be resolved with a standard
git pullorgit pushThere are three possible scenarios to resolve a merge conflict usegit statusto see the file in question that is causing the merge conflict
git stash allows you to save your local changes after staging them
git add .
git stashgit log will show a history of all the commits to a remote repo
git log can take arguments like the below command
git log {arguments}some sample git log arguments are listed below
git log --oneline
git log --decorate
git log --graph
git log -p
git log --stata useful example of combining arguments is listed below
git log --oneline --graphto see the three most recent commits run the below command
git log -3below are various git log commands with arguments
git log --after=βyesterdayβ
git log --author=βipatchβ
git log --no-mergesCompare file changes with git diff
git diff --stat
git diff --cachedto see who modified a file last run the below command
git blame someFile.rbto see a list of tags in a repo run the below command
git tagto create a tag for a repo, run the given example below
git tag v1.0.0to push the local tags to a remote repo, run the following
git push --tagsto grab the latest version of the remote code, use following
git fetchto rebase a branch interactively run the below command
git rebase -i origin/mastergit bisect allows you to track down a problem in code on a commit to commit basis.
to start a bisecting state run the below command
git bisect startto label a commit good / bad run the following command
git bisect bad
git bisect gooda test suite such as Rspec can run all its test before a git commit is made
Example - create the following file in .git/hooks/pre-commit
the below command will write to the global .gitconfig in the userβs home dir
git config --globalto set the editor for git run the below command
git config --global core.editor vimaliases can be created using something similar to the below command
git config --global alias.graph βlog --graph --onelineβRemove unnecessary tracking git tracking with .gitignore files to remove a tracked file from a git repo
git rm --cachedto remove ALL .DS_Store files from a git repo add the below line to .gitignore
**/.DS_Store
These notes wouldn't be possible if the below course wasn't created.
git for everyday professional use
cheers π»
Chris
If you find any of this info helpful on your journey π click that π βοΈ star button. It sure makes me feel warm and fuzzy π» on the inside.
-
Linux and macOS Operation Notes
- β macOS Op Notes
- π§ Linux Op Notes
- Vim & Neovim Notes
- git Notes
- π fish shell Notes
- ECMAScript Tooling
- π₯§ Raspberry Pi Notes
- asdf version manager Notes
- Bind9 Notes
- Creating a custom motd on Debian Jessie
- ECMAScript Tooling
- Email client Notes
- Email Server Setup Notes Postfix & Dovecot
- Emoji side quest
- fish shell Notes
- π₯ π€ git it got it good Notes
- git Notes
- Graphics and Image Processing Notes
- GUI text editor Notes
- π»π§ Homebrew and Linuxbrew formula Notes
- Linux and macOS Administration Notes
- Linux and macOS Troubleshooting Notes
- MacBook Pro Late 2013 Notes
- Vim & Neovim Notes
- Video Production Notes
- Python Notes
- radare Notes
- Raspberry Pi Notes
- Terminal Emulators
- Tmux Notes
- Web Browser Notes
- Weechat Notes
- Microsoft Windows Notes