bare parameter allows that:
ssh git@example.com mkdir my_project.git cd my_project.git git init --bare git update-server-info # If planning to serve via HTTP exit
cd my_project git init git add * git commit -m "My initial commit message” git remote add origin git@example.com:my_project.git git push -u origin master
git remote add origin ssh://estudiobay/repos/wallstreetjournal/demo.unity.git git remote add origin ssh://wikis/var/www/repos/shellscripts/
git remote add newskid ssh://newskid/home/ubuntu/repos/backend.git git push newskid
git clone ssh://estudiobay/repos/fcbarcelona/gamepass.android.git/
git remote -vgit statusgit loggit remote -vgit show REVISION:path/to/filegit log --graph --oneline --abbrev-commit
Remove file without removing from directory:
git rm --cached mylogfile.log
For a directory:
git rm --cached -r mydirectory
$ git reset --hard HEAD~ $ git push -f
$ git commit -A
$ git reset HEAD path/to/unwanted_file
git reset HEAD~
git rm --cached -r -- .
git reset --hard HEAD git clean -f -d
git checkout filename
git checkout -- filename
git clean -f -d
git checkout -b [name_of_your_new_branch]git checkout [name]git push origin [name_of_your_new_branch]git branchgit branch -d the_local_branchgit push origin :the_remote_branchgit checkout -b my_new_branch git commit
git branch -D no_queues
git push origin --delete test
git checkout -b <local_name> <remote_name> git checkout -b no_queues remotes/origin/#001_no_queues
git stashgit stash listgit pop stash@{1}git stash cleargit checkout 45a33 (it's not needed to put all the identifier)git checkout mastergit branch
List tags: git tag -l
Create a tag in the current commit: git tag -a 2.4.5
Upload tags to the remote: git push origin –tags
Remove a tag:
git push --delete origin <tagname>
You need to set denyCurrentBranch
$ git init $ git config receive.denyCurrentBranch ignore <then you can push> $ git checkout <desired_branch>
If you want to return to the default behavior:
$ git config receive.denyCurrentBranch refuse
And to update:
git reset --hard
Create a submodule linked directly to the theme’s GitHub repository in order to receive updates:
$ git submodule add https://github.com/tomanistor/osprey.git themes/osprey $ git submodule update --init --recursive --remote
To update a downloaded repo with submodules:
$ git submodule init $ git submodule update
You should always keep in mind that you can return to the state before you started the merge at any time. This should give you the confidence that you can't break anything. On the command line, a simple git merge –abort will do this for you.
In case you've made a mistake while resolving a conflict and realize this only after completing the merge, you can still easily undo it: just roll back to the commit before the merge happened with git reset –hard and start over again.
Create a bundle file:
git bundle create your_name.bundle --all
Use it:
git clone <path_to_bundle_file>
https://stackoverflow.com/a/14757539
If you type git reflog, it will show you the history of what revisions HEAD pointed to. Your detached head should be in there. Once you find it, do git checkout -b my-new-branch abc123or git branch my-new-branch abc123 (where abc123 is the SHA-1 of the detached HEAD) to create a new branch that points to your detached head. Now you can merge that branch at your leisure.
Generally, if you check out a branch after working on a detached head, Git should tell you the commit from the detached head you had been on, so you can recover it if you need. I've never used SourceTree, so I don't know if it relays that message. But if it did display that message, then you should be able to use that to find the commit, and again use git checkout -b or git branch to create a branch from that commit.
git config --global core.editor "nano -w"
To use it for the current repo:
$ git mergetool -t meld
To configure git to remember which merge tool you want, type git config –global merge.tool [tool]. For meld use:
$ git config --global merge.tool meld
You can have as many remotes as you want, but you can only have one remote named “origin”. The remote called “origin” is not special in any way, except that it is the default remote created by Git when you clone an existing repository. You can configure a second remote, push to/pull from that remote, and setup some branches to track branches from that remote instead of origin.
Try adding a remote called “github” instead:
$ git remote add github https://github.com/Company_Name/repository_name.git # push master to github $ git push github master # Push my-branch to github and set it to track github/my-branch $ git push -u github my-branch # Make some existing branch track github instead of origin $ git branch --set-upstream other-branch github/other-branch
Other easier:
git remote add gitea https://git.alfredgg.dev/gtd/docker-without-pants.git git push gitea
$ git -C /home/alfred/Documents/workspaces/python/newskid.frontend push
For one day (86400), one hour (3600)…
git config --global credential.helper 'cache --timeout 86400'
git config credential.helper store
Git global setup
git config --global user.name "user1" git config --global user.email "user1@test.com"
Create a new repository
git clone http://127.0.0.1/user1/test.git cd test touch README.md git add README.md git commit -m "add README" git push -u origin master
Existing folder
cd existing_folder git init git remote add origin http://127.0.0.1/user1/test.git git add . git commit -m "Initial commit" git push -u origin master
Existing Git repository
cd existing_repo git remote rename origin old-origin git remote add origin http://127.0.0.1/user1/test.git git push -u origin --all git push -u origin --tags