Set Git to store credentials
Below command can be executed from anywhere in your system.
git config --global credential.helper wincred
Turn off Warning _LF will be replaced by CRLF_
git config core.autocrlf true or git config --global core.autocrlf true
In Unix systems the end of a line is represented with a line feed (LF). In windows a line is represented with a carriage return (CR) and a line feed (LF) thus (CRLF). when you get code from git that was uploaded from a unix system they will only have an LF.
Mark local folder as git folder
Add / Link remote repository to local repository
git remote add origin https://github.com/JitendraZaa/sfdx-object-export
Add new / multiple remote repository
git remote set-url origin https://github.com/JitendraZaa/sfdx-object-export
Clone complete repository
Git clone Example : Git clone https://github.jitendraZaa.com/CPQ/cpq-salesforce.git
Clone git repository with branch
Git clone -b Example : Git clone -b Dev1 https://github.jitendraZaa.com/CPQ/Salesforce-Backup.git
Git fast forward push
git push --force
Ignore a file temporarily or Remove a file from staged area or commit everything except one file
Run below command before commit, to ignore file
git reset -- "FileName"
Run below command before commit, to ignore file in folder
git reset -- "Folder/FileName"
Run below command before commit, to ignore every file in folder
git reset -- "Folder/*"
Ignore every change in local git repository
Run below all 3 commands in sequence
git reset --hard git reset --hard Example : git reset --hard origin git pull
Rollback last Git command
git lastcommand --revert
Example if we want to revert last pull command then run below command
git pull --revert
Change or Switch Branch
git branch -m new-name
If you are on different branch
git branch -m old-name new-name
Once Branch renamed, push branch, it will create new and then run delete command for branch
Delete remote branch
git push origin --delete
Current code base points to which branch
starred branch would be current branch
Create a branch and switch to new branch
git checkout -b CPQAdmin
CPQAdmin is new branch name
Push branch to remote
git push origin CPQAdmin
CPQAdmin is branch name to be pushed
Status of modified or added files
Add all local changed files for commit
git add .
Delete local deleted file from remote also
git add -u .
Commit with message
git commit -m "My custom message"
Create gitignore file
above command will create gitignore file
git tag -a v0.1 -m "Information about Tag"
Push local tag to remote
git push --tags
clear git cache
Sometimes gitignore file does not work. So, we need to clear the cache using below command
git rm -r --cached .
Get List of files changed in last 24 hours
Below commands should be executed in local git folder
git pull origin git log --pretty=format: --name-only --since="24 hours" | sort | uniq > OutputFileName.txt
After running above command, new file with name OutputFileName.txt would be created which will have list of all components changed in last 24 (n) hours.
Save Password in Git Store
If you are not using SSH keys then you might end up providing password every time. We can run below command to let Git store your password so you don’t have to remember it
git config credential.helper store
After above command, execute pull request