Showing posts with label git. Show all posts
Showing posts with label git. Show all posts
Friday, May 11, 2018
git commit all deleted files at one time
There are couple of options to do batch commit of deleted files.
git add . => Add all (tracked and modified)/new files in the working tree.
git add -u => Add all modified/removed files which are tracked. (stages removed file and modifiled files, then git commit -m 'message')
git add -u folder/ => Add modified/removed files under the folder
git add -A => Add all (tracked and modified)/(tracked and removed)/new files in the working tree. (similar to git add -u, but also adds new files.)
git commit -a -m "commit message" - Add and commit modified/removed files which are tracked.
git ls-files --deleted -z | xargs -0 git rm
git rm $(git ls-files --deleted)
My personal perfer is git add -A and git add -u
Wednesday, December 13, 2017
GitLab Commands
After create a new repository on gitlab, it usually gives below command line instructions.
Git global setup
git config --global user.name "Jim Zhao"
git config --global user.email "jim@example.com"
Create a new repository
git clone https://gitlab.com/jimzhao/test.git
cd test
touch README.md
git add README.md
git commit -m "add file"
git push -u origin master
Existing folder
cd existing_folder
git init
git remote add origin https://gitlab.com/jimzhao/test.git
git commit -m "init message"
git push -u origin master
Existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin https://gitlab.com/jimzhao/test.git
git push -u origin --all
git push -u origin --tags
How to check changes on remote origin git repository?
There are couple of ways and lots of discussion regarding check changes on remote git repository.
git remote update - bring your remote refs up to date
git status - tell you whether the branch you are tracking is ahead, behind or has diverged
git show-branch *master - show commits in all of the branches whose names end in master (eg master and origin/master)
git pull origin master - bring my local up to date
git fetch origin - update the remote branch in your repository to point to the latest version
git diff origin/master - diff local against the remote
git merge origin/master - accept the remote changes
git remote show origin - Show synthetic view of what's going on remote "origin" repository
Tuesday, December 12, 2017
Git 101
git add - Add file contents to the index.
git branch - List, create, or delete branches
git bisect - Find by binary search the change that introduced a bug
git checkout - Checkout a branch or paths to the working tree
git clone - Clone a repository into a new directory
git commit - save staged changes to local repository
git diff - Show changes between commits, commit and working tree, etc
git fetch - download objects and refs from another repository
git grep - Print lines matching a pattern
git init - reate an empty Git repository or reinitialize an existing one
git log - show commit logs
git merge - Join two or more development histories together
git mv - Move or rename a file, a directory, or a symlink
git pull - Fetch from and merge with another repository or a local branch
git push - Update remote refs along with associated objects
git rebase - Rebasing is the rewinding of existing commits on a branch with the intent of moving the branch start point forward, then replaying the rewound commits.
git reset - Reset current HEAD to the specified state
git rm - Remove files from the working tree and from the index
git show - Show various types of objects
git status - Show the working tree status
git tag - create tagging.
git help xxx - to show help info
Subscribe to:
Comments (Atom)