Git Useful commands
Github project creation:
Steps:
echo "# audio" >> README.md
git init git add README.md git commit -m "first commit" git branch -M main git remote add origin https://github.com/yourGitRepositoryLink git push -u origin main
Update password
git remote set-url origin https://{new url with username replaced}
git remote set-url origin https://YOURUSERNAME:YOURPASSWORD@1.1.1.1.1/yourteam/appname.git
Git commands list:
mac-YourName:~ username$ git checkout -b feature-branch master
mac-YourName:~ username$ git pull
# 2.1 - overwrite local with git pull
mac-YourName:~ username$ git stash
mac-YourName:~ username$ git pull
do a dry-run to see what will be deleted
mac-YourName:~ username$ git clean -n -d
after, do git clean to delete it
ac-YourName:~ username$ git clean -f -d
adding files to the working tree means you are adding them to the staging area, means you are staging them.
mac-YourName:~ username$ git add
If you want git to stop tracking specific files on the working tree, you need to remove them from your stage files...
Checkout master branch : $git checkout master
Get list of all merge commit : $git log --oneline
Revert merge by commit : $git revert -m 1 <merge-commit-id>
Commit the revert and push changes to the remote repo : $git commit -m "revert merge #123 "
Remove files: $git rm <file-1> <file-2>
Commit your changes : $git commit -m "removing files"
Push changes : $git push
$git diff branch_1..branch_2
produce difference : $git diff master...branch_test
compare difference : $git diff branch1:file branch2:file
checkout branch to rename: $git checkout <old-name>
rename branch locally: $git branch -m <new-name>
delete old branch from remote: $git push origin :<old-name> <new-name>
reset the upstream branch for the new branch name: $git push origin -u <new-name>
Comments
Post a Comment