Git Practices
-
git config --global user.email "you@example.com"
-
git config --global user.name "Your Name"
For All File Replace FileName by .
-
git add "FileName"
-
git restore --staged "FileName"
Undo last commit without file staged condition.(Only for local/offline repository)
-
git reset --soft HEAD^
-
git branch branch-name
-
git checkout branch-name
-
git checkout -b branch-name
-
To delete a branch, you must leave off the branch that you want to delete and run this command.
git branch --delete branch-name
When our OS is changed but user and directory is same.
-
git config --global --add safe.directory 'Directory With Path'
then, add email and user name.
This command is recursive and cleans both the current directory and any subdirectories.
-
git clean -f -d
This command will help when remote repo has changed as well as we need to change in local repo.
-
git pull
This command will help when local repo has changed as well as we not need to change in remote repo.
-
git reset --hard
When below command run,then given below error shows
git push origin master
fatal: unable to access 'https://github.com/rkpust/PostgreSQL.git/': Failed to connect to github.com port 443 after 21093 ms: Couldn't connect to server
-
git config --global http.proxy ""